-1

I am looking for a kind of tool that gives me the possibility to define a certain region of interest (ROI) (maybe a rectangle area) within an image file. The ROI should be stored somehow within the metadata of the image.

Further I am looking for a kind of tool, that would be capable to automatically crop and scale the image to different aspect ratios.

The use case would for example a high res landscape picture of a person. So I could define the face and a little space surrounding as my ROI and store this within the file. The face might not be in the center of the image.

If now I would need a portrait version of this image, maybe 480x640px, I would start my tool that could interpret this ROI information and tries to do its best with cropping and scaling, to best fit the face within the cropped image.

Is this something that could be done with Photoshop or ImageMagick? I spent some time to look for this stuff, but did not find any good solution. Technically it seems not to be rocket science (at least I assume)...

I appreciate any hint or feedback.

Best regards

Hape

Hape
  • 11
  • 3

1 Answers1

1

You may like to look at clipping paths which can be stored in TIFF images, and others with the necessary 8BIM profile, and accessed via ImageMagick, see here . See also -clip-mask and -clip-path just below.

Or you may like to roll your own.... you could set the ROI in a comment with ImageMagick like this:

convert image.jpg -set comment "100x120+580+260" image.jpg

or

mogrify -comment "100x120+580+260" image.jpg

or

jhead -cl "100x120+580+260" image.jpg

enter image description here

and later extract it like this:

identify -format %c image.jpg
100x120+580+260

And maybe use it like this:

convert image.jpg -crop $(identify -format %c image.jpg)  ROI.jpg

enter image description here

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432