Jimp: how to set write() to base64

Created on 7 Aug 2018  路  1Comment  路  Source: oliver-moran/jimp

i want to make the result of image manipulation to base64
so i can display it without store the image on my server
this is my code

const Jimp = require('jimp');
const base64 = require('node-base64-image');
var imgs = "https://scontent-sin6-1.cdninstagram.com/vp/86449fc9f74675290a52d4e2a133fdf9/5C0C1F53/t51.2885-15/e35/19436764_1153046358134464_2721742701283246080_n.jpg"

Jimp.read('frame.png',function (err,frame) {
  base64.encode(imgs, {string: true}, function (err, image) {
      if (err) {
          console.log(err);
      }
       Jimp.read(Buffer.from(image.replace(/^data:image\/png;base64,/, ""), 'base64'),function (err,img) {
        if (err) {
          console.log(err);
        }
        let image_final = img
        .resize(1000,1000)
        .rotate(180)
        .composite(frame,0,0)
        .write('final_ig_180.jpg')
                base64.encode(image_final, {string: true}, function (err, final_img) {
          console.log(final_img);
        })
      })
  })
})

but the result is undefined

Most helpful comment

just use the base64 function instead of write

Jimp.read(
  'https://scontent-sin6-1.cdninstagram.com/vp/86449fc9f74675290a52d4e2a133fdf9/5C0C1F53/t51.2885-15/e35/19436764_1153046358134464_2721742701283246080_n.jpg'
).then(img => {
  img.getBase64(Jimp.AUTO, (err, res) => {
    console.log(res)
  })
});

>All comments

just use the base64 function instead of write

Jimp.read(
  'https://scontent-sin6-1.cdninstagram.com/vp/86449fc9f74675290a52d4e2a133fdf9/5C0C1F53/t51.2885-15/e35/19436764_1153046358134464_2721742701283246080_n.jpg'
).then(img => {
  img.getBase64(Jimp.AUTO, (err, res) => {
    console.log(res)
  })
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

laino picture laino  路  5Comments

Jimbly picture Jimbly  路  5Comments

Yimiprod picture Yimiprod  路  5Comments

jBernavaPrah picture jBernavaPrah  路  4Comments

master-of-null picture master-of-null  路  3Comments