-
-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does vips CLI use some default quality parameter while converting images? #571
Comments
Hi, vips webp write defaults to Q 75, the jpeg standard. ImageMagick seems to default to Q 80. |
cwebp uses 75 as the default as well: https://developers.google.com/speed/webp/docs/cwebp So I think ImageMagick is the odd one out here. |
So I am actually using sharp for these transformations and maybe you and @lovell can help me understand how the quality parameter at sharp interacts with the quality parameter of libvips and the existing image quality. This is the sequence of transformations that are being carried out where artefact appears in the output image. This is the sequence where the artefact does not appear. Because sharp sets Q=80 by default, this would happen on any two successive transformations. What should be the quality settings on each of the steps to get the result without artefact and with quality 80, assuming that the operation has to be carried out in two steps and not one. |
In terms of sharp, JPEG and WebP should both be considered lossy formats, in that you'll see compression artefacts creeping in with every decompression+compression round trip (lossless WebP support is coming soon). A JPEG image at "80% quality" will be different to a WebP image at "80% quality" as the latter achieves a smaller file size by discarding more data. |
Yes, I agree with @lovell. In your case 1. I think you are doing jpeg decompress -> webp compress -> webp decompress -> jpeg compress, and each of those compressions will introduce image errors. I would use a lossless format for intermediates, or better still, do all the processing in a single pipeline. |
So converting the initial JPEG, Q-80 to PNG for all intermediate transformations and the final PNG in the required format and quality should work fine right? |
png is extremely slow, I would use vips format, or failing that, tiff. |
There's a benchmark resizing a large image on another issue:
So with png format, you are spending >90% of total CPU time just in libpng decompress/recompress. png is much slower than jpg, even though the compression algorithm is very simple. Never use png for anything, unless you have to. |
Is there any particular reason why TIFF cannot be an output format (while writing to buffer) in sharp? Is it because of the larger size of TIFF images? |
libtiff just makes it slightly fiddly to code. libvips 8.5 has tiff output to buffer support and I imagine sharp will add support once 8.5 is done. |
I was able to reproduce your problem at the command-line:
If you load This makes an image with no blocking:
But of course the file is a little larger. I think your solutions are:
|
But is this something that can be corrected? Because even in other examples, and I can share those as well, the artefact is always on the top-right side. Could this probably be some issue with libvips around how resizing is handled? Will this go away with the near-lossless and lossless settings that are to be added in libvips? Also, another image example If I resize it down to 100px width (command line vips), I start getting a border around the image which is probably because of the white to transparent transition |
Is this exposed via sharp? Also, for normal JPEG images, what performs better, |
Oh, to answer your first question, this looks like a problem with webp, I don't think it's anything to do with libvips. |
Yes, sharp's resize does this for you automatically. |
Is this something that was added in sharp v0.17? Because v0.16 gives the edge. |
@RNanwani Yes, v0.17.0 improved things in certain situations - see lovell/sharp#605 |
Sorry, I missed this question: Also, for normal JPEG images, what performs better, vips resize or vipsthumbnail?
|
Default was 75 (libvips/libvips#571 (comment)) Resolves #57
This is the original image that I am considering
https://cdn18.nnnow.com/web-images/medium/styles/Y1NM5TM5P4L/1474025249507/1.jpg
This is at Q=80 originally.
I used cwebp and libvips CLI to convert this JPG to WebP using the following commands
cwebp ~/Desktop/original.jpg -o ~/Desktop/original-cwebp.webp
vips copy ~/Desktop/original.jpg ~/Desktop/original-vips.webp
Using either of these commands, results in a strange artefact in the top right corner of the image.
However, if I specify either Q=80 or greater in either of these commands or use ImageMagick to do the conversion, then I don't get the artefact. What is the possible reason for this?
The image on the right is the converted webp. Note the block artefacts at the right hand side of the image.
The text was updated successfully, but these errors were encountered: