Page 1 of 1

Use image property/attribute in image transformations

Posted: 2014-11-26T10:56:47-07:00
by oleksiy
Is there any way to set an image property (in sequence for example) and use that property for crop/resize/etc?

For example I can do the following (pseudocode):

Code: Select all

image.jpg ( -size 300x300 -annotate 0x0+0+0 "TEXT' -set option:textsize '%wx%h+0+0' ) ( -clone 0 -annotate 0x0+0+0 '%[textsize]' ) -composite
And I will get the correct dimensions string "printed".

But I can't do the following:

Code: Select all

image.jpg ( -size 300x300 -annotate 0x0+0+0 "TEXT' -set option:textsize '%wx%h' ) ( -clone 0 -crop '%[textsize]' -blur 0x7 ) -composite
It seems that -crop simply doesn't parse/resolve this variable.

Is there any way to use variables (options) set with -set in -crop/-resize/etc and not only -label and -annotate?

Re: Use image property/attribute in image transformations

Posted: 2014-11-26T11:27:17-07:00
by fmw42
Not that I know in IM 6 that way. In IM 7, you will be able to do things like that. IM 6 has limited functions that recognize -set options. I do not think crop and resize (or anything which uses geometry) can do that. In -distort, however, you can do computations right in the arguments and in the virtual-canvas that controls size and offset. So you can use -distort SRT to change size and use the viewport to crop. See

http://www.imagemagick.org/Usage/distor ... t_viewport
http://www.imagemagick.org/Usage/distor ... red_square
http://www.imagemagick.org/Usage/distorts/#srt

Re: Use image property/attribute in image transformations

Posted: 2014-11-26T12:16:31-07:00
by oleksiy
Many thanks!