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 transformation with no compression/resizing looses quality

See original GitHub issue

When reading and jpeg image from file and writing it back to a different file without applying any transformations it loses size. Example:

sharp('original.jpg').withMetadata().toFile('transformed.jpg');

During the tranformation output is following:

vips warning: exif: bad exif meta "exif-ifd3-GPSVersionID"

The version or sharp that is being used: v0.20.7 file output:

file *.jpg
original.jpg:    JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=16, height=3968, bps=0, width=2976], baseline, precision 8, 2976x3968, frames 3
transformed.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=15, height=3968, bps=0, width=2976], baseline, precision 8, 2976x3968, frames 3

The image that is being transformed original.jpg: original Transformed image transformed.jpg: transformed Node versoin: v8.11.4 OS: Ubuntu 18.04

Is this an expected behavior? What options could be specified to avoid any transformatios but still use sharp for writing the output file (this is needed due to specifics of wrapper library implementation)?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nazcommented, Aug 30, 2018

@lovell thanks! that approach worked, but as @rodrigoalviani mentioned it makes the image that is to be processed bigger size than it initially was. The use case for this processing was an image uploader in Ghost (https://github.com/TryGhost/Ghost/pull/9837). Initially, the idea was to allow configuring compression level and metadata stripping, but we decided to go with defaults that sharp uses as they are just the right ones we wanted in place. Because quality/compression configuration is so different between jpeg, png, webp etc. The more granular configuration will be available if users find a need for it eventually. Cheers!

0reactions
rodrigoalvianicommented, Aug 30, 2018

On the mostly cases, 100% quality increases original file size. 95% could be enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Resize Image Without Losing Quality - KeyCDN Support
The quality of your images is very important. Follow this short tutorial on how to resize image without losing quality and still achieve...
Read more >
How to Resize an Image without Losing Quality - HubSpot Blog
Learn how to resize an image without losing quality to improve your website speed and improve the user experience.
Read more >
How To Resize Images Without Losing Quality Using GIMP ...
We'll be covering how you can resize your images without losing quality with GIMP since it's a free piece of software that anyone...
Read more >
JPEG quality loss: why it happens and how to manage it
Re-saving an already compressed image leads to the so-called “photocopier effect” meaning that an image loses its quality due to being resaved ...
Read more >
How to Compress Your Image Files Without Losing Quality
Previously, the image had 6 values, whereas the following compression, only 3 values are present in the image, which saves up 50%. 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