Re: How do I get the offset result from "-trim"?

Bob Friesenhahn <[email protected]> Fri, 14 Aug 2020 08:19:12 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Fri, 14 Aug 2020, Adam Richter wrote:
>>
>> There are likely implications if/when the bug is fixed since it may
>> influence the results of other algorithms.
>
> Thanks for such a prompt response, Bob.
>
> I have found a workaround: add "-format %@" and remove "-trim", for example:
>
> $ gm convert -fuzz 20% -format "%@" 001_bordered.pnm info:-
> 2617x3328+2+2,

That is really interesting.  The GM manual page says this about "%@":

   %@   trim bounding box

> By the way, ImageMagick and GraphicsMagic gave me different bounding
> boxes when I used "-fuzz 30%":
>
> $ magick convert -fuzz 30% -format "%@\n" 001_bordered.pnm info:-
> 2409x2837+119+133
> $ gm convert -fuzz 30% -format "%@" 001_bordered.pnm info:-
> 2572x3199+22+2
>
> I don't know if that matters or if one is right and the other is
> wrong.  I am guessing that this is some different between
> GraphicsMagick's
> FuzzyColorMatch() and ImageMagick.  Anyhow, it is not a problem for
> me, but I figure I ought to pass along this additional observation
> in case it is of any interest.

The algorithm for finding the bounding box has likely changed in 
modern ImageMagick.  After 18 years of separation, some differences 
may be expected.  What the ImageMagick project does does not define 
what the GraphicsMagick project does, although we do try to be 
responsive to user demands and do pay attention.  A visual inspection 
of the image is likely required to see what the most correct answer 
likely is.

> Although the issue is no longer causing me a problem, please feel free
> to let me know if I can be of assistance in any way if you decide to
> dig into this issue further now or in the future.

Well, you do appear to be a quite clueful user and given that at the 
moment I appear to be the only significant contributor to 
GraphicsMagick, any feedback or even source patches from you are 
valuable.  This applies to anybody who is able to contribute to the 
project in a way which helps more than it hurts.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt