coloring wrote:do you mean IM v7 can do it and IM v6 can not?

This trimming can be done pretty easily using either IM6 or IM7. It's just that ImageMagick 7 can often reduce a process like this to a single command. Using IM 6.7.7 from a bash shell prompt I can do something like this to accomplish your task...
Code: Select all
inimage=YZu6yZx.gif
trimmer=`convert $inimage -coalesce -flatten -format %@ info:`
convert $inimage -coalesce -crop $trimmer +repage result.gif
That runs the "convert" command once to get the trim specs and put them in a variable. Then it runs another "convert" command using that variable to do the actual work. You could, of course, nest that first "convert" command with backticks inside the second where the "$trimmer" variable is. It still runs the "convert" command twice.
Using ImageMagick 7 you'd be able to obtain the trimming specs and trim the image all in one command, calculating the dimensions and offsets and applying those to the crop directly instead of putting those specs in a shell variable as an intermediate step. I don't have IM7 installed on a *nix machine, but using IM 7.0.4 from a Windows CMD prompt, a command like this would do it...
Code: Select all
set INIMAGE=YZu6yZx.gif
magick %INIMAGE% -coalesce ^
( -clone 0--1 -flatten -set option:trimmer %@ +delete ) -crop %[trimmer] +repage result_IM7.gif
Of course when processing a very small image like this, the difference in time or resource usage wouldn't likely be a concern.