Page 1 of 1

Pure geometry calculations without an actual image

Posted: 2014-09-01T16:17:08-07:00
by hakunin
Is there a way to supply original width/height (not an image, just 2 numbers) to convert or identify command, and receive a resulting width/height based on a geometry, as if an actual image was resized? For example: I would supply 1000,600 (w/h) and geometry '600x600>' and I should get 600,360 on output. If I supply 500,400 with the same geometry, I would get 500,400 on output (since I used ">", which does shrink-only).

In my imagination it would look something like this:

Code: Select all

$ identify -calc -width 1000 -height 600 -geometry 600x600> -format "%wx%h"
600x360
This is useful for me because the images are uploaded to S3, and I don't want to download them in order to find out the final sizes, or having to store those sizes in the database for every thumbnail. I also wouldn't want to have to reimplement all the geometry logic in my programming language of choice, if I could simply call imagemagick to do the native calculation.

Re: Pure geometry calculations without an actual image

Posted: 2014-09-01T16:51:12-07:00
by fmw42
-geometry doing resize is a special case and should be avoided in general. You should use -resize or -thumbnail. see http://www.imagemagick.org/Usage/resize/#geometry

Code: Select all

convert -size 1000x600 xc: -resize  "600x600>" -format "%wx%h" info:
600x360