PNG images saves all meta data that is a normal image "-set" You don't have to store it as 'virtual canvas and offset' in the image which can confuse other programs. For example some old web browsers go crazy on images with negative offsets.
Code: Select all
convert wizard: -set my:crop 70x70+200+104 a.png
identify -format '%[my:crop]' a.png
70x70-200-104
Unfortunately IMv6 does not understand escape sequences in all arguments, so you need to extract the information from the image as a separate shell/DOS command. Here I use the above 'identify' as a UNIX shell command substitution.
Code: Select all
convert a.png -crop `identify -format '%[my:crop]' a.png` show:
But you can cheat by using a no-op distort viewport to do that crop in one command.
Code: Select all
convert a.png -set option:distort:viewport '%[my:crop]' -distort SRT 0 show:
IMv7 "magick" command does understand percent escapes in almost all options (Not in FX Escapes yet ;( )
Code: Select all
magick a.png -crop '%[my:crop]' show:
Now while PNG (and MIFF) can save all 'set' metadata, JPEG and GIF can not. Thye do however have comments.
For examples see IM Examples, Montage, Using Saved Image MetaData
http://www.imagemagick.org/Usage/montage/#metadata