when I use the following code with a corrupt image I get the error "marker was not found" but I can not capture it using "catch (function (err) {".
How can I catch the error?
Jimp.read(localFilePath).
then(function (image) {...........}).
catch(function (err) {
console.log('get error');
});
C:\Users\xxx\Documents\progetto\node_modules\jpeg-js\lib\decoder.js:323
throw "marker was not found";
^
Could you upload the corrupt image for testing? Thanks.
Hi,
Any updates about this issue ??
I just got the same problem with this code:
jimp.read(file_path, function(err, image) {
image.resize(96, 58)
.write(small_file_path, function() {
return fSuccess(image);
});
});
Can't catch exception either.
The corrupt file.

Thanks.
same
馃憤
Is there a way to track down what this means and why it happens? I have a worker set up to convert large images on S3 to thumbnails and of 427 images 23 of them are throwing marker not found errors, and I cant for the life of me figure out why and how to resolve.
OK. I'm going to do a release in the next few days. Will make this bug an priority for the release after that.
OK. This seems to be catching correctly now:
Jimp.read("file.jpg").then(function(image) {
image.scale(0.5).write("file-sm.jpg");
}).catch(function (err) {
console.log(err);
});
Closing issues.
Getting the error "marker was not found in the console".Below is my code:
var request = https.get(url, function(response) {
response.pipe(file);
file.on('finish', function() {
file.close(cb); // close() is async, call cb after close completes.
});
Jimp.read(dest).then(function (lenna) {
lenna.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write(dest); // save
}).catch(function (err) {
console.log("error found")
console.error(err);
});
}).on('error', function(err) { // Handle errors
fs.unlink(dest); // Delete the file async. (But we don't check the result)
if (cb) cb(err.message);
});
I'm trying to use node-thumbnail which I believe use the Jimp library. I'm passing an array of images to the thumbnail generating function and I'm getting the same "marker was not found" issue. I'm pretty sure none of my images is corrupted and I can't seem to work my way out of this
I am facing the same issue Error: marker was not found
I am also facing the same issue. I have checked my image on which i am making processing and it is not corrupted image.
Error in Jimp.read() Error: marker was not found
at decodeScan (/var/task/node_modules/jpeg-js/lib/decoder.js:344:15)
at constructor.parse (/var/task/node_modules/jpeg-js/lib/decoder.js:799:29)
at Object.decode [as image/jpeg] (/var/task/node_modules/jpeg-js/lib/decoder.js:1091:11)
at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/utils/image-bitmap.js:196:53)
at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/index.js:431:32)
at /var/task/node_modules/@jimp/core/dist/index.js:373:15
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
methodName: 'constructor'
}
I have the same problem. I'm getting "marker was not found" on random images (about 1 out of 20 or so). I am also getting "marker was not found" on all images on imgur.com, like https://i.imgur.com/hYQQslz.jpg
Same issue.
For anybody else having the same issue, I tested that I could just retry and it would almost always return correctly on the second try. So I added my own resizing part into a small recursive wrapper:
async function retryResize(options, retries = 0) {
let { imagePath, size, quality = 60, maxRetries = 5 } = options;
let image = null;
try {
image = await Jimp.read(imagePath);
await image.resize(size, Jimp.AUTO);
await image.quality(quality);
} catch (e) {
if (retries >= maxRetries) {
throw e;
}
image = await retryResize(options, retries++);
}
return image;
}
Just change the options and the steps of the try block.
Most helpful comment
I am also facing the same issue. I have checked my image on which i am making processing and it is not corrupted image.
Error in Jimp.read() Error: marker was not found at decodeScan (/var/task/node_modules/jpeg-js/lib/decoder.js:344:15) at constructor.parse (/var/task/node_modules/jpeg-js/lib/decoder.js:799:29) at Object.decode [as image/jpeg] (/var/task/node_modules/jpeg-js/lib/decoder.js:1091:11) at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/utils/image-bitmap.js:196:53) at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/index.js:431:32) at /var/task/node_modules/@jimp/core/dist/index.js:373:15 at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) { methodName: 'constructor' }