Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: marker was not found #935

Open
krishnaTORQUE opened this issue Aug 30, 2020 · 5 comments
Open

Error: marker was not found #935

krishnaTORQUE opened this issue Aug 30, 2020 · 5 comments
Labels
bug there is a bug in the way jimp behaves help wanted

Comments

@krishnaTORQUE
Copy link

krishnaTORQUE commented Aug 30, 2020

Expected Behavior

Image processing successfully

Current Behavior

Error: marker was not found

Failure Information (for bugs)

bug

Steps to Reproduce

try {
    let img = await jimp.read(imagePath)
    await img.cover(300, 300)
    await img.quality(80)
    await img.rgba(false)
    await img.background(0xffffffff)

    await img.writeAsync(savePath + imgName)

    console.log('success')
  } catch (e) {
    console.log(e)
  }

Context

its not happening all the time. sometime the error occur, sometime not with the same image.

  • Jimp Version: 0.16.1
  • Operating System: ubuntu 20.04
  • Node version: 12.18.3

Failure Logs

Error: marker was not found
at decodeScan (/mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/jpeg-js/lib/decoder.js:344:15)
at constructor.parse (/mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/jpeg-js/lib/decoder.js:804:29)
at Object.decode [as image/jpeg] (/mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/jpeg-js/lib/decoder.js:1096:11)
at Jimp.call (/mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/@jimp/core/src/utils/image-bitmap.js:165:21)
at Jimp.parseBitmap (/mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/@jimp/core/src/index.js:400:17)
at /mnt/KrishnaTorque/Projects/NodeJS/02/dxtrez/src/node_modules/@jimp/core/src/index.js:344:14
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
methodName: 'constructor'
}

@kvintessents
Copy link

The same is happening to me.

@ajayKomirishetty
Copy link

I am facing the same issue

@amiran-gorgazjan
Copy link

For anyone facing the same issue, I found a workaround which is simply re-trying it multiple times. If let's say it happens 1 out of 100 times (99% success rate) then with a second re-try it happens 1 out of 10000 times in total, etc. This code retries 5 times.

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;
}

Notice that this function does still does throw when it fails the 5th time, so make sure you deal with that - although I have yet to see it actually happen.

@rendomnet
Copy link

same issue.

@stefanleoussis
Copy link

Same issue

@hipstersmoothie hipstersmoothie added help wanted bug there is a bug in the way jimp behaves labels Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug there is a bug in the way jimp behaves help wanted
Projects
None yet
Development

No branches or pull requests

7 participants