Page 1 of 1

Writing large png images got twice as slow

Posted: 2016-07-31T05:53:14-07:00
by chregu
Hi

Upgraded from imagemagick 6.7.8 to 7.0.2 and now saving large png images got twice as slow (it happens already with 6.8)

Test image is here: https://www.dropbox.com/s/iunlia3yr0lxprk/test.jpg?dl=0

Code: Select all

$ time ImageMagick-6.7.8-10/utilities/convert -version -debug all test.jpg png:/dev/null 2> /tmp/debug-6.7.log
Version: ImageMagick 6.7.8-10 2016-07-29 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

real	0m6.271s
user	0m6.136s
sys	0m0.128s
debug-6.7.log is here: https://gist.github.com/chregu/f1246cfa ... 173aac0ad8

Code: Select all

$ time ImageMagick-7.0.2-5/utilities/convert -version -debug all test.jpg png:/dev/null  2> /tmp/debug-7.0.log
Version: ImageMagick 7.0.2-5 Q16 x86_64 2016-07-30 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): freetype jng jpeg ltdl lzma png tiff webp xml zlib

real	0m13.731s
user	0m13.476s
sys	0m0.160s
debug-7.0.log is here: https://gist.github.com/chregu/98c5a5cc ... 9e4f3b1175

As you can see from the log, it spends most of the time in

Code: Select all

2016-07-31T12:46:59+00:00 0:01.050 1.050u 7.0.2 Coder lt-magick[18873]: png.c/WriteOnePNGImage/11075/Coder
      Writing row of pixels (3)
2016-07-31T12:47:12+00:00 0:13.690 13.610u 7.0.2 Coder lt-magick[18873]: png.c/WriteOnePNGImage/11171/Coder
    Wrote PNG image data
There's no significant difference with smaller images or eg. jpg output

I also tried different compile settings (disabling openmp for example), nothing made any difference.

It all runs on an amazon linux instance (which is some form of CentOS, don't know exactly which version, but can figure that out, if important)

Any hint what's going on here would be really appreciated.

Re: Writing large png images got twice as slow

Posted: 2016-07-31T06:20:26-07:00
by chregu
Realized the examples above for IM 7.0.2 were compiled with Q16, but doesn't make a difference with Q8:

Code: Select all

$ time ImageMagick-7.0.2-5/utilities/convert -version -debug all test.jpg png:/dev/null  2> /tmp/debug-7.0.log
Version: ImageMagick 7.0.2-5 Q8 x86_64 2016-07-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): freetype jng jpeg ltdl lzma png tiff webp xml zlib

real	0m12.949s
user	0m12.820s
sys	0m0.116s
and here's the log file: https://gist.github.com/chregu/657a7054 ... 69b9c91d36

Re: Writing large png images got twice as slow

Posted: 2016-07-31T07:16:57-07:00
by snibgo
There have been many changes since that old version that affect speed. Is the size of the output file (in bytes) different?

Try with "-define colorspace:auto-grayscale=off".

Try with different "-quality" settings. This make no difference to quality, as PNG is lossless, but does change the speed versus filesize tradeoff.

PNG is not a great format for photographs -- it is designed for graphics, and is slow for photos. I find that TIFF with no compression is about ten times as fast.

Re: Writing large png images got twice as slow

Posted: 2016-07-31T07:39:11-07:00
by chregu
Oops. Quality and filesize I didn't check. When I set -quality to the same values, they're approx the same speed and size. Thanks a lot for the quick answer. helped a lot already.