question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image bigger (in bits) after sharp operation than the original

See original GitHub issue

After using sharp like this with a jpg

await sharp(input).trim().toFile(output);

or

await sharp(input).resize({ width: 1000 }).toFile(output);

the output is bigger than the original picture original: 300 Kb trimed: 7 Mb resize: 7 Mb

Any advices ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lovellcommented, Nov 24, 2021

Thanks, this input image is saved at a very low quality:

$ identify -verbose PHO_211124_35029728_1_135049727.jpg | grep Quality
  JPEG-Quality: 13

If you’d like a similar low quality for the output, you can set this via:

.jpeg({ quality: 13 })

https://sharp.pixelplumbing.com/api-output#jpeg

Finally, to answer your next question before you’ve asked it, please see #908

0reactions
parwebcommented, Nov 24, 2021

nice anticipation 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image to composite must have same dimensions or smaller ...
The operation composite should allow greater images than the source image. It should use the source image dimensions.
Read more >
Image resize results in massively larger file size than original ...
JPG images to a max width, but it's resulting in images being larger in kb than the source. What am I doing wrong?...
Read more >
How to Resize an Image Correctly | The TechSmith Blog
Making an image to be larger than its original dimensions can be tricky. Resizing an image larger than its original dimensions can affect...
Read more >
How To Process Images in Node.js With Sharp - DigitalOcean
Image compression is the process of reducing an image file size without losing quality. First, you'll chain the resize() method from the sharp ......
Read more >
Processing images with sharp in Node.js - LogRocket Blog
To resize the image, we first chain the resize() function to the sharp instance. Then, we save it in the processed_images folder. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found