ImageMagick7 runs much slower than version6

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick7 runs much slower than version6

Post by fmw42 »

Correct. That is what I wrote earlier in this topic.

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

the one you talk about limit thread is this below?
convert -limit thread 1 src.png -resize 4000x5000! -format %@ -write info: -trim +repage -bordercolor none -border 5 dest.png

I try this but got errors

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick7 runs much slower than version6

Post by fmw42 »

It works fine for me.

Code: Select all

convert -limit thread 1 b07s8dt2vc-large-front_image.png -resize 4500x5400! -format %@ -write info: -trim +repage -bordercolor none -border 5 result.png
3739x5194+452+57

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

Hi,
does that mean HDRI has been disabled?
looks like it is still slow. do I need also disable OpenMP? if it is, do you know how to do it?

[niyanwen@mftp-ygw-i-d-2a-43520b1f]/apollo/env/MerchFTProductionAssetManagerService/bin% ./convert -version
Version: ImageMagick 7.0.8-37 Q16 x86_64 2019-10-08 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms png raw tiff webp xml zlib

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick7 runs much slower than version6

Post by fmw42 »

-limit thread 1 just disable your 16 processors and forces Imagemagick to use just 1. It has nothing to do with HDRI. To disable HDRI or OpenMP, you have to recompile ImageMagick. I doubt disabling OpenMP will make a difference since -limit thread 1 did not seem to help.

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

oh I haven't try limit 1 yet, now I just tried disable HDR I found in some posts says it will help, I saw another suggestion is try add -quality 21?
https://www.imagemagick.org/discourse-s ... hp?t=27672

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

looks like limit thread helps and speed improve a lot!

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

fmw42 wrote:
2019-10-08T16:44:23-07:00
-limit thread 1 just disable your 16 processors and forces Imagemagick to use just 1. It has nothing to do with HDRI. To disable HDRI or OpenMP, you have to recompile ImageMagick. I doubt disabling OpenMP will make a difference since -limit thread 1 did not seem to help.
just one concern is what do you mean disable 16 processors and force to just use 1?
for if this host has another image magick command running, is it acceptable?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick7 runs much slower than version6

Post by fmw42 »

It only disables the other processors for the command for which -limit is set, not for the server. But that did not help, so no point in doing -limit. However, if your hosting provided disables OpenMP or HDRI, that would affect the whole server and all users. So that is not likely going to happen if you are on a shared server.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick7 runs much slower than version6

Post by snibgo »

Multi-threading can be disabled per command, but HDRI is a build-level switch.

I use at least two versions of IM: HDRI when I need precision, and non-HDRI when I need speed. This may not be feasible on a shared server.
snibgo's IM pages: im.snibgo.com

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

limit thread help, so now I am doing 1. limit 2. disable HDR 3. add quality to improve the speed, thank you guys!

niyanwen
Posts: 81
Joined: 2019-05-23T16:19:12-07:00
Authentication code: 1152

Re: ImageMagick7 runs much slower than version6

Post by niyanwen »

IM6 is limit thread 1 by default?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick7 runs much slower than version6

Post by snibgo »

niyanwen wrote:IM6 is limit thread 1 by default?
No. "convert -list resource" shows the limit:

Code: Select all

Resource limits:
  Width: 214.7MP
  Height: 214.7MP
  List length: 18.446744EP
  Area: 6.4068GP
  Memory: 2.9834GiB
  Map: 5.9668GiB
  Disk: unlimited
  File: 1536
  Thread: 8  <<========
  Throttle: 0
  Time: unlimited
On my computer, the limit is 8.
snibgo's IM pages: im.snibgo.com

ethaniel
Posts: 6
Joined: 2015-04-22T15:46:32-07:00
Authentication code: 6789

Re: ImageMagick7 runs much slower than version6

Post by ethaniel »

I rebuilt ImageMagick 7 without OPENMP, HDRI and set to Q8. It is still much slower than imagemagick 6 (100-110ms per image vs 80ms per image).

Code: Select all

./configure --enable-shared --enable-symbol-prefix --with-quantum-depth=8 --enable-hdri=no CFLAGS="-I/opt/libjpeg-turbo/include" LDFLAGS="-L/opt/libjpeg-turbo/lib64" --disable-openmp

Code: Select all

Version: ImageMagick 7.0.9-14 Q8 x86_64 2020-01-09 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC
Delegates (built-in): bzlib fontconfig freetype jng jpeg lcms lzma png tiff webp xml zlib

Code: Select all

convert -list resource
Resource limits:
  Width: 429.497MP
  Height: 429.497MP
  Area: 10.7374GP
  List length: unlimited
  Memory: 5GiB
  Map: 10GiB
  Disk: unlimited
  File: 375000
  Thread: 1
  Throttle: 0
  Time: unlimited

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick7 runs much slower than version6

Post by magick »

See https://imagemagick.org/script/porting.php. You'll find that IMv7 handles multi-spectral images. That means that channels are handled individually as an array of channels. Looping through the channels has a performance hit vs. IMv6 which handles RGBA as a single packet. There are tradeoffs for this enhancement. For example, for IMv7 you can process a 1-channel gray image whereas with IMv6, a gray image consumes 4 channels even for a 1-channel gray image. Here IMv7 requires 25% of the memory that IMv6 does for gray images. So in some cases, IMv7 will be much faster than IMv6 and in others, IMv6 performance will outpace that of IMv7.

Locked