jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
13.97k stars 762 forks source link

name too long open base64 image #751

Open haoxl3 opened 5 years ago

haoxl3 commented 5 years ago

Expected Behavior

jimp can read image url

Current Behavior

jimp can't read image url

Failure Information (for bugs)

name too long open 'data:image/jpeg;base64,...'

Steps to Reproduce

Jimg.read(this.orignSrc).then(image => {
         image.color([{apply: val, params: [100]}]).getBase64(Jimg.AUTO, (err, src) => {
                this.doingImg.src = src;
        });
});

then I got 'name too long, open "data:image/jpeg;base64,..."' this.orignSrc is a base64 image

Screenshots

image

Context

sorry, none

Failure Logs

eidyz commented 5 years ago

What I have done to get around this is something like

loadFile(e) {
      const file = e.file.originFileObj;
      const url = URL.createObjectURL(file);
      Jimp.read(url).then(img => ...)
}
Liental commented 3 years ago

any updates on that issue?

Liental commented 3 years ago

If anyone needs a workaround, you can try doing it that way

const buff = Buffer.from(base64string.split(',')[1], 'base64');
const image = await Jimp.read(buff);