I found jpeg images generated by sharp are not compatible with some software.
The file command output of sharp generated image is different from images generated by other image lib (jimp/gimp/PIL etc), there is no JFIF standard 1.01, aspect ratio, density 1x1 prefix.
$ file other.jpg sharp.jpg
sharp.jpg: JPEG image data, baseline, precision 8, 1080x565, frames 3
jimp.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 800x391, frames 3
// "sharp": "^0.17.1"
export default async function compressImage(data) {
const destData = await sharp(data)
.limitInputPixels(MAX_PIXELS)
.resize(MAX_WIDTH, MAX_HEIGHT)
.background('white')
.max()
.withoutEnlargement()
.flatten()
.jpeg({quality: 65})
.toBuffer()
return await destData
}
Hello, the JFIF standard (rather than the JPEG standard) requires a mandatory APP0 metadata chunk. Adding withMetadata should do this.
Are you able to provide an example of "some software" that can't handle APP0-less JPEG?
@lovell Thank you, it works now.
Amazon Kindle (E-Ink version)'s builtin .mobi viewer (in periodical mode) does not show images without metadata.
Most helpful comment
@lovell Thank you, it works now.
Amazon Kindle (E-Ink version)'s builtin .mobi viewer (in periodical mode) does not show images without metadata.