You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
are passed to the decoder when decoding an image from a Buffer or a file.
Current Behavior
Decoder options are not passed to the underlying decoder, unless the first argument in Jimp.read(url, options) is a URL. This leads to, e.g., the inability to decode large JPEGs due to memory errors, since maxMemoryUsageInMB cannot be set.
Failure Information (for bugs)
I suspect the issue is that the read() method returns this.fromBuffer(...) instead of this.fromBuffer(..., options) unless the first argument is a URL.
staticasyncread(url: string|Buffer|ArrayBuffer,options?: MimeTypeToDecodeOptions){if(Buffer.isBuffer(url)||urlinstanceofArrayBuffer){returnthis.fromBuffer(url);// <--------------------------------- here}if(existsSync(url)){returnthis.fromBuffer(awaitreadFile(url));// <---------------------- here}const[fetchErr,response]=awaitto(fetch(url));if(fetchErr){thrownewError(`Could not load Buffer from URL: ${url}`);}if(!response.ok){thrownewError(`HTTP Status ${response.status} for url ${url}`);}const[arrayBufferErr,data]=awaitto(response.arrayBuffer());if(arrayBufferErr){thrownewError(`Could not load Buffer from ${url}`);}constbuffer=bufferFromArrayBuffer(data);returnthis.fromBuffer(buffer,options);// <---------------------- but here returns correctly}
Context
Jimp Version: 1.6.0
Operating System: Windows 10
Node version: 22.11.0
The text was updated successfully, but these errors were encountered:
Expected Behavior
When using
Jimp.read()
, decoder options, e.g.are passed to the decoder when decoding an image from a Buffer or a file.
Current Behavior
Decoder options are not passed to the underlying decoder, unless the first argument in
Jimp.read(url, options)
is a URL. This leads to, e.g., the inability to decode large JPEGs due to memory errors, sincemaxMemoryUsageInMB
cannot be set.Failure Information (for bugs)
I suspect the issue is that the
read()
method returnsthis.fromBuffer(...)
instead ofthis.fromBuffer(..., options)
unless the first argument is a URL.Context
The text was updated successfully, but these errors were encountered: