lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.33k stars 1.3k forks source link

How to maintain oiriginal image quality? #4202

Closed henryfra14 closed 2 months ago

henryfra14 commented 2 months ago

I'm trying to watermark or resize the original image.

and I want to save it in jpeg format and maintain the quality of the original image.

When saving after work, the quality seems to be set to default 80.

If the quality of the original image is 90, is there a way to save or output the work result while maintaining this quality?

await sharp('image.jpg')
.composite([{input: watermark, gravity: 'centre'}])
.jpeg({
   quality: 100
})

Should I set the quality to 100 as above to maintain the same quality as the original image? Or is there another way?

lovell commented 2 months ago

Please see #908