0

I am trying to build an image manipulation API using ImageMagick.I am not able to compress the PNG images to the required level. How do I imitate this https://blog.imgix.com/2016/03/11/auto-compress.html behavior for PNG's using ImageMagick!!

Sainath
  • 45
  • 4
  • Imagemagick does not have an auto-compress capability for PNGs. You have to specify the desired quality. See http://www.imagemagick.org/script/command-line-options.php#quality. Or non-imagemagick tools such as at http://www.imagemagick.org/Usage/formats/#png_non-im – fmw42 Jul 04 '18 at 02:24

1 Answers1

1

PNG compression is lossless. Therefore, there is a image size reduction limit.

The article in question says:

...

auto=compress reduced the file size by over 99%, with no loss in quality.

Note: Files without transparency will be output as JPEG. If your illustrations are saved as PNG without transparency, this will lead to a loss in image quality.

So, if auto=compress gets a PNG image without transparency, it converts it to JPEG.

EDIT: Also, have you considered looking at existing APIs like the API of the CloudImage service? They use better algorithms and I think it is worth to look into it.