mistergoomba wrote:These lines produce different results:
Code: Select all
convert halloween_category.gif -crop 60x60-10+10\! halloween_cropped.gif
convert amber.jpg -crop 60x60-10+10\! amber_cropped.jpg
halloween_cropped.gif comes out as a 60x60 image with 10 pixels of whitespace on the left. amber_cropped.jpg comes out as a 50x60 image.
Actually internally they BOTH come out as 50x60 pixel images (actual number of pixels in the actual image cropped. That was because the -10 means the crop slightly missed the image, so the image does not 'fill' the 60x60 pixel area.
The '!' caused the crop to generate a ,
'viewport' crop which cause the cropped image to be set on a virtual canvas the same size as the crop area at the position given. That is 60x60, and causing the 50x60 pixel actual image to be located at a +10+0 on the 60x60 virtual canvas.
However the difference in the results is that the JPEG file format does not handle virtualk canvas information at all. so you just get the 50x60 actual image and nothing else.
GIF file format however can save the virtual canvas information so the 'white' area is just the 'empty part of the GIF's virtual canvas that did not have the image overlaid. The white would be the white of the PAGE BACKGROUND not from the image.
If you want to 'fill out' the missing area, add
-flatten to the command.
Code: Select all
convert halloween_category.gif -crop 60x60-10+10\! -background white -flatten halloween_cropped.gif
convert amber.jpg -crop 60x60-10+10\! -background white -flatten amber_cropped.jpg
That will replace the virtual canvas with a real image (of the current background color) and overlay the image at +10+0. That is it will 'fill in' the pixels missing from the 'viewport' which is no longer needed afterwards.
As the virtual canvas has been 'filled' ALL image file formats will handle it the same way as their is no virtual information to cause problems.
See Virtual Canvas info and the 'page' options that control it.
http://www.imagemagick.org/Usage/basics/#page