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

Corrupt JPEG data: premature end of data segment, even with failOn set to 'none' #3825

Open
lsrbrrd opened this issue Oct 13, 2023 · 1 comment

Comments

@lsrbrrd
Copy link

lsrbrrd commented Oct 13, 2023

I have a issue resizing jpg image, it is a corrupted file but I need to process it too, could you please help me, thanks

the code
const readStreamObject = await s3Client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
const objectBuffer = await new Promise((resolve, reject) => {
const chunks = [];
readStreamObject.Body.on('data', (chunk) => {
chunks.push(chunk);
});
readStreamObject.Body.on('error', (err) => {
reject(err);
});
readStreamObject.Body.on('end', () => {
resolve(Buffer.concat(chunks));
});
}
);

fixedImageBuffer = await sharp(objectBuffer, { failOn: 'none' })
.resize({ width: 900, height: 675 })
.withMetadata()
.toBuffer();

corrupted

@lsrbrrd lsrbrrd added the triage label Oct 13, 2023
@lovell
Copy link
Owner

lovell commented Oct 14, 2023

Hi, thanks for reporting, this looks like the problem that libvips/libvips#3293 is trying to solve where the failOn setting is ignored for some truncated JPEG images.

@lovell lovell changed the title VipsJpeg: Corrupt JPEG data: premature end of data segment Corrupt JPEG data: premature end of data segment, even with failOn set to 'none' Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants