Image transformation with no compression/resizing looses quality
See original GitHub issueWhen 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
:
Transformed image transformed.jpg
:
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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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!
On the mostly cases, 100% quality increases original file size. 95% could be enough.