Skip to content

Commit

Permalink
Disable Jimp JPEG decoder memory limit
Browse files Browse the repository at this point in the history
It's capped at some fixed value, which botches loading images of larger
resolutions for no good reasons This disables the limit in the deferred
image manipualtion worker. Presumably the same manipulation isn't
necessary in the non-deferred variant, since those images are tiny.

Upstream issue: jimp-dev/jimp#915
  • Loading branch information
askmeaboutlo0m committed Aug 12, 2023
1 parent f644694 commit b03dd7c
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ setTimeout(() => {
process.exit(1);
}, 60000 * 30);

// Work around Jimp's hard-coded memory limit when loading JPEG files.
// See https://github.com/jimp-dev/jimp/issues/915
(function () {
const decoder: any = Jimp.decoders['image/jpeg']
Jimp.decoders['image/jpeg'] = (data: any) => {
const userOpts = { maxMemoryUsageInMB: Number.POSITIVE_INFINITY };
return decoder(data, userOpts);
}
}());

let manipulator = null; // JIMP
process.on('message', async (msg: any) => {
let hasChanges = false;
Expand Down

0 comments on commit b03dd7c

Please sign in to comment.