Re: Filters not being applied during a resize operation

Bob Friesenhahn <[email protected]> Sun, 19 Feb 2012 15:01:20 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Wed, 15 Feb 2012, Steven Bakhtiari wrote:

> Hi all,
> 
> This post may be more appropriate for some other mailing list, if so, please let me know.

This is a good place.

> We have a small wrapper application that utilises the GraphicsMagick lib to perform a bunch of operations on images
> requested via HTTP. Using our tool, I discovered that filters weren’t being applied to the resized images, so I decided to
> investigate.
> 
> My first port of call was to try using the GM CLI tool in an attempt to replicate the problem. I found that when passing
> the filter flag  after the resize flag, the filter wasn’t being applied. Placing the filter flag before the resize flag
> produces the expected result. Knowing this, I decided to take a look at the source code to our tool, but as it’s a pretty
> simple wrapper, it just makes standard use of the API; It makes a call to:
> 
> MagickResizeImage(MagickWand *,const unsigned long,const unsigned long,
>     const FilterTypes,const double)

You have discovered a long-standing bug which was inherited from 
ImageMagick.  It turns out that ResizeImage was obtaining the filter 
to use from the 'filter' member of the Image structure rather than the 
'filter' argument.

Several times I have heard complaints that the resize filter was not 
being used but disregarded them because it obviously worked from the 
command line and the C++API.  Now I know why there were complaints.

> So now I’m at a loss… I’m guessing that the GM CLI tool makes a very similar call, so I’m not sure why it would make a
> difference in which order the filter flag is passed.

Arguments are parsed from left to right, similar to the English 
language.  When a command argument (e.g. -resize) is executed, it uses 
the attribute settings which were already parsed.

I have just fixed the bug.  It is changeset 41dae3dd3710 in Mercurial. 
You can find the tiny patch to magick/resize.c at 
http://graphicsmagick.hg.sourceforge.net/hgweb/graphicsmagick/graphicsmagick/diff/41dae3dd3710/magick/resize.c

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis