Page 1 of 1

MagicWand Performance vs ImageMagic

Posted: 2009-03-11T00:55:57-07:00
by MGSteve
I thought MW should be quicker than running the IM commands via the shell? Turns out its not and by some margin.

I had a image library of 2,065 images and wrote a script to convert them from JPGs to PNG files.

Via MW, it took 473.8 seconds
Via IM, to took 415.9 seconds

Is that expected, if not are there ways to speed MW up? Although I suspect the influence of PHP code in the coversion process isn't helping, forking to run the convert im command via the shell is probably going to be quicker, come to think of it. Although I would have thought it would have saved a bit by not having to fork.

Anyway, just thought it was interesting to note the difference.

Re: MagicWand Performance vs ImageMagic

Posted: 2009-03-11T05:39:56-07:00
by magick
Both the command line and MagickWand are simply wrappers around the MagickCore API so you can expect equivalent performance for your image processing tasks. Apparently there are some differences in your command line and MagickWand calls but without seeing both we cannot comment.

Do you have a modern version of ImageMagick? The latest is 6.5.0-0. Recent versions of ImageMagick run in parallel and sometimes you can achieve substantial speed-ups in your workflow if you have a multi-core system

Re: MagicWand Performance vs ImageMagic

Posted: 2009-03-13T04:18:05-07:00
by MGSteve
magick wrote:Both the command line and MagickWand are simply wrappers around the MagickCore API so you can expect equivalent performance for your image processing tasks. Apparently there are some differences in your command line and MagickWand calls but without seeing both we cannot comment.

Do you have a modern version of ImageMagick? The latest is 6.5.0-0. Recent versions of ImageMagick run in parallel and sometimes you can achieve substantial speed-ups in tour workflow if you have a multi-core system
It was a basic convert from JPG to PNG. I've got 6.45 installed, compiled from source.

'Version: ImageMagick 6.4.5 2008-11-04 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC'

And I do have a multi-core system, hopefully this version I compiled should make use of it?

The IM call via PHP was

Code: Select all

$Command = "convert -quality 75 $SrcFile $DestFile";
The MW code was

Code: Select all

    $wSrc = NewMagickWand();
    MagickReadImage( $wSrc, $SrcFile );

    $FileFormat = $this->GetMagickFormatFromFileName($DestFile);
    MagickSetFormat($wSrc, $FileFormat);
    
    if ($FileFormat == 'JPG')
    {
      MagickSetImageCompression($wSrc, MW_JPEGCompression);
      MagickSetImageCompressionQuality($wSrc, 75);
    }

    if (MagickWriteImage($wSrc,$DestFile))
    {
      chmod($DestFile,0644);
      return true;
    }