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.88k stars 760 forks source link

Reading base64 image from a Buffer is slow #1294

Open Dylan190774 opened 3 months ago

Dylan190774 commented 3 months ago

In a browser app I'm reading a base64-string from a buffer. The original image is 3072 x 512 pixels. This takes quite a while to be read (around 500 ms). Is this normal behaviour?

The image is made of 6 webpimages of 512x512 each, which I merge with the merge-images package, since Jimp doesn't support reading webp. The reading of the 6 separate image files, merging them and outputting this to a base64-string with merge-images takes only about 250 ms in total.

Here's my code:

    const base64 = '<...  the base64 string of 6 merged webp images...>';
    const url = base64.replace(/^data:image\/\w+;base64,/, '');
    const buffer = Buffer.from(url, 'base64');

    await Jimp.read(buffer)
      .then((img) => {

           //this takes about 500 ms

      }};

My system is not slow at all and it has 16GB of memory.

Any idea's why reading from a base64 string is this slow?

xalteropsx commented 1 month ago

agree it very insanely slow

hipstersmoothie commented 2 weeks ago

Feel free to contribute a PR to fix! jimp is a community project