Re: Filters not being applied during a resize operation
"Steven Bakhtiari" <[email protected]> Mon, 20 Feb 2012 09:02:57 -0000
| Newsgroups | gmane.comp.video.graphicsmagick.apis |
|---|---|
| Message-ID | <5311D057033B204C99839A152F59B8BE07ED6C33@bbcxues12.national.core.bbc.co.uk> |
Hi Bob, Thank you very much for the response (and even more so for fixing the issue) - it's very much appreciated. I was starting to go a little bonkers; I was ready to break out gdb and learn how to debug C code! Thanks again, Steven -----Original Message----- From: Bob Friesenhahn [mailto:[email protected]] Sent: 19 February 2012 21:01 To: Steven Bakhtiari Cc: [email protected] Subject: Re: [GM-apis] Filters not being applied during a resize operation 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/ http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Graphicsmagick-apis mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis