I'm trying to use Jimp to process images that are about 70-100 MB is size. However, I get the following error
// image is 87.7 MB
Jimp.read('big-image', (err, img) => {
console.log(err)
})
> Error: maxMemoryUsageInMB limit exceeded by at least 226MB
Is there any way around this?
I get this issue in 0.16.0 but not 0.9.8.
same issue heare (0.16.1)
Same issue with 0.16.1
I have same problem. So I tried fix something.
[(https://developer.aliyun.com/mirror/npm/package/jpeg-js)]
On this site, there are maxMemoryUsageInMB option on decode function.
And I change [email protected]:196 line.
this.bitmap = this.constructor.decoders[_mime](data);
to
this.bitmap = this.constructor.decoders[_mime](data, {maxMemoryUsageInMB: 2000});
Then I can read the large image. Try this one.
Having the same issue, 10mb jpgs turn into 1.1gb+ ram usage and crash with Error: maxMemoryUsageInMB limit exceeded
Happens on newest jimp and the newest windows server
I'm having the same issue.
Our problem has only been reported from users with a specific phone model (Huawei P30).
We're using JIMP to compress and resize images taken from a native mobile application.
Running version:
"jimp": "^0.16.0"
Same problem here, any update?
I get this issue in 0.16.0 but not 0.9.8.
worked for me.
I have same problem. So I tried fix something.
[(https://developer.aliyun.com/mirror/npm/package/jpeg-js)]
On this site, there are maxMemoryUsageInMB option on decode function.And I change [email protected]:196 line.
this.bitmap = this.constructor.decoders[_mime](data);
to
this.bitmap = this.constructor.decoders[_mime](data, {maxMemoryUsageInMB: 2000});Then I can read the large image. Try this one.
This works locally but not working with the live app. How do I fix it
Downgrading to 0.9.8 worked for me as well.
if error is maxResolutionInMP limit exceeded by 36MP
this.bitmap = this.constructor.decoders[_mime](data, {
maxResolutionInMP:400
});
You can fix by overriding the jpeg-js decoder jimp uses as follows:
Jimp.decoders['image/jpeg'] = (data: Buffer) => JPEG.decode(data, { maxMemoryUsageInMB: 1024 });
@hisham where do we put this code? I converted it to regular js like so
Jimp.decoders['image/jpeg'] = (data) => JPEG.decode(data, { maxMemoryUsageInMB: 1024 })
But I get JPEG undefined. Can you help? Thank you
You put it before you use any Jimp operations - i.e.:
import JPEG from 'jpeg-js';
constructor() {
Jimp.decoders['image/jpeg'] = (data: Buffer) => JPEG.decode(data, { maxMemoryUsageInMB: 1024 });
}
myMethod(image: Buffer) {
const jimpImage = await Jimp.read(jpegBuffer);
}
Just a question. How will you handle memory for 'image/tiff' images ?
Is the following correct for NodeJS ?
const jimpJPEG = require('jpeg-js')
const jimpTIFF = require('utif')
jimp.decoders['image/jpeg'] = (data) => {
return jimpJPEG.decode(data, {
maxMemoryUsageInMB: 1024
})
}
jimp.decoders['image/tiff'] = (data) => {
var ifds = jimpTIFF.decode(data, {
maxMemoryUsageInMB: 1024
})
var page = ifds[0]
jimpTIFF.decodeImages(data, ifds)
var rgba = jimpTIFF.toRGBA8(page)
return {
data: Buffer.from(rgba),
width: page.t256[0],
height: page.t257[0]
}
}
Any update?
problem is here: node_modules/@jimp/core/dist/utils/image-bitmap.js -> node_modules/jpeg-js/lib/decoder.js
Having this same problem too. Is there any major difference between the 0.9 and 0.16 versions?
Most helpful comment
I have same problem. So I tried fix something.
[(https://developer.aliyun.com/mirror/npm/package/jpeg-js)]
On this site, there are maxMemoryUsageInMB option on decode function.
And I change [email protected]:196 line.
this.bitmap = this.constructor.decoders[_mime](data);to
this.bitmap = this.constructor.decoders[_mime](data, {maxMemoryUsageInMB: 2000});Then I can read the large image. Try this one.