Search code examples
imagecropgifgraphicsmagick

GraphicsMagick - cropping JPEG and converting to GIF results in black bar


I have a 1280x720 JPEG that I want to convert to a 720x720 GIF. When I simply crop without setting x & y offsets, it works fine:

gm convert -crop 720x720 images/one.jpg images/test.gif

But I want to keep the content centered/crop data off the edges. When I do that but do not convert to GIF, that works as well

gm convert -crop 720x720+280+0 images/one.jpg images/test.jpg

But when I both try to crop with offsets and convert to GIF, I wind up with a GIF that is properly centered and cropped, but there is a 280px black bar on the left side covering the content (or maybe it's just empty black space, as it is not bumping anything over):

gm convert -crop 720x720+280+0 images/one.jpg images/test.gif

I'm using GraphicsMagick v 1.3.20 in the bash shell on Mac running OSX 10.9.5


Solution

  • I don't know GM, only ImageMagick, but there at least, it is generally a good idea to use repage to remove any offsets that sneak in when cropping or changing geometry.

    You should be able to see if there are any offsets by using the identify command-line tool:

    identify image.png
    image.png PNG 10x10 300x100+5+5 8-bit sRGB 2c 299B 0.000u 0:00.000
    

    Note the offset of +5+5 above.