LosslessJpegDecoder is undefined
See original GitHub issueExpected Behavior
Jimp should be able to process DNG files.
Current Behavior
Jimp throws an error LosslessJpegDecoder is undefined.
Failure Information (for bugs)
import Jimp from 'jimp';
I’m using Jimp within an AWS Lambda function. When I import Jimp to perform conversion on a DNG to base64, I get the error LosslessJpegDecoder is undefined. This occurs before I perform any image processing.
I’ve found the line in jimp.js that appears to instantiate a LosslessJpegDecoder, and I can’t see where a LosslessJpegDecoder would be defined. From jimp@0.4.0, jimp.js:31737:
if(img["t262"]==32803) // lossless JPEG (used in DNG files) is not available in JpegDecoder.
{
var bps = img["t258"][0], dcdr = new LosslessJpegDecoder();
I can’t find any references to LosslessJpegDecoder anywhere else in the code. Where is this supposed to come from?
I have found a snippet of code identical to the snippet above in the utif package (https://github.com/photopea/UTIF.js/blob/master/UTIF.js). I believe Jimp uses utif but I’m not sure how. It’s possible that this is utif’s problem, not Jimp’s, but since I’m not directly relying on utif I thought I would open this issue.
Steps to Reproduce
- Import jimp in an AWS Lambda function.
Screenshots
Context
This problem occurs in an AWS Lambda function.
- Jimp Version: 0.4.0
- Operating System: AWS Lambda … probably AmazonLinux
- Node version: 8.10
Failure Logs
2018-10-24T15:00:40.166Z - error: Error in vision processing LosslessJpegDecoder is not defined
Notes
It’s possible that this is a utif problem, not a jimp problem, but since they contain some identical code I wanted to ask in both places. Thank you for your help.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19

Top Related StackOverflow Question
@rdhenderson see what i was saying? I never knew a try/catch was so scary
Thanks @rdhenderson. Yes it works - all that’s needed is for @jimp/type-tiff to update its utif dependency to 3.1.0.
In the meantime I just installed the latest utif as a dependency on my project and overwrote the UTIF decoder with as follows: