Page 1 of 1

PNG geometry and the *original* image canvas

Posted: 2015-02-04T17:48:31-07:00
by gb96
Used the following to crop a directory full of PNG images:

Code: Select all

mogrify -crop 1080x300+0+0 *.png
Expected resulting images to be 1080x300 however I did not realize that the PNG preserves geometry reference of the *original* image, and the source images to the above command were the output of a previous been crop, as follows:

Code: Select all

mogrify -crop 1080x1920+0+181 *.png
The end result of the 1080x300+0+0 crop have dimensions of only 1080x119 and ruined all the images. So glad I have a backup of the source images somewhere!

I think this default behavior is counter-intuitive, and should be either changed or at least better documented. The initial crop and subsequent operations could have been performed by different users or processes and so geometry should by default be relative the the input image, not to some ancient "original" version.

Re: PNG geometry and the *original* image canvas

Posted: 2015-02-04T17:52:34-07:00
by fmw42
You probably want to add +repage after the crop, if you do not want to save the virtual canvas. If they were cropped previously with the virtual canvas, put another +repage before the crop.