sic icon indicating copy to clipboard operation
sic copied to clipboard

Compare the size of the output image (resize by vips and resize by sic)

Open EasiestSoft opened this issue 4 years ago • 3 comments

Sampling filter: lanczos3 Input image: in.png 825x515, 202 KB Output image: out.png 990x618

Output image size:

  • sic: 505 KB
  • vips: 305 KB

I prefer to use sic to adjust image size, but the increased 200KB size is a problem

https://github.com/libvips/libvips

Another thing is that the default image sampling filter in vips is lanczos3. Generally, we can use lanczos3 to get high-quality output images. Can we use lanczos3 as the default sampling filter too?

EasiestSoft avatar Apr 07 '20 10:04 EasiestSoft

Sic is practically a front-end for the image crate. It is unlikely that a change in sic can resolve this problem. If your use case has the absolute requirement to have images with sizes as small as possible, sic may currently not be your best option 🙂.

That said, I'm happy to help and willing to have a look into it anyway (or into the image crate if necessary). For that we need to:

  1. check if this isn't an outlier, i.e. we need a larger, public set of test images to ensure it's consistent (I wouldn't be surprised if this isn't an outlier since libvips seems to exist for longer than the image crate does, and went through more optimization)
  2. locate where the problem occurs and if there are shorter paths to achieve smaller file sizes (like setting a flag in the image crate's config) than possibly rewriting image's PNG compression.

If you are looking for images sized as small as possible, you may wish to also look at pngcrush, Zopfli using (eg) AdvanceCOMP or optipng.

You may also look at alternative cli's e.g. image magick, which are more mature.

I'll split off your last request (setting lanczos3 as the default sampling filter) to a new issue. #339

foresterre avatar Apr 07 '20 19:04 foresterre

Thank you for your quick reply and detailed help information

Image size is not a big issue for local use, but it is important for publishing images on the web. I have tested pngquant and Oxipng to reduce the image size, and currently use pngquant to compress png files

https://github.com/kornelski/pngquant https://github.com/shssoichiro/oxipng

I also added sic and the tools you mentioned here to the awesome-compiled list:

https://github.com/EasiestSoft/awesome-compiled

EasiestSoft avatar Apr 08 '20 00:04 EasiestSoft

Today, I use the golang tool imaging to adjust the size of the same image, out.png is 330 KB, this result is similar to the image generated by vips (305KB)

https://github.com/disintegration/imaging

EasiestSoft avatar Apr 08 '20 01:04 EasiestSoft