I'm using Imagemagick version 7.0.5-4 to perform image processing operations like crop, resize etc with go-graphics library. I also manage a pool of magickwand objects.
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
The read time of image to MagickWand object as magickWand.ReadImage(<url>)
in png images is very high compared that of jpg images. For images of size around 22kb, reading a jpg file takes around 300ms and that of png image takes around 1-2 minutes.
Edited:
When a single request is sent to server, the read operation takes around 20ms, but when on load of 100rps, it goes till 2-4 minutes. This trend is only in png images, not in jpg.
Any ideas on what can be done different in reading png files and how it can be made performant? Its fine to reduce the quality of images to around 60%. Tried options like SetImageDepth
but it made no difference.
The compression quality parameter has a different effect and meaning when dealing with PNG files from when dealing with JPEG files.
PNG compression is always lossless and the appearance is never affected by the quality. As I cannot see your images, I would suggest you either don't bother compressing since it will happen anyway, or that you use a quality of 75. If you tell me you are saving cartoons or line drawings, I might advise differently.
Please have a read here and do some experiments yourself with the tradeoff between time and filesize.
I have made you some plots to show the effect on time to compress and compressed size for different quality settings using two different kinds of images - cartoons and photos - so you can see the effect.
Here is a cartoon:
Look at how the quality setting (0-100) affects time and size with JPEG output:
Now look what happens if you use those same quality settings (0-100) when generating PNG output:
Now let's look at compressing an iPhone photo to JPEG:
And when compressing an iPhone photo to a PNG:
Hopefully you can see that using one quality setting from your config file for both PNG and JPEG and with photos and cartoons/line drawings is not ideal.