Page 1 of 1

expressions as arguments

Posted: 2015-04-10T06:33:09-07:00
by GreenKoopa
Is there a way to use an expression for crop's geometry? I've done this with -distort, -print, and filenames. Does it work anywhere else? I vaguely remember someone getting this to work for -size xc:, but I can't find the post.

convert in.jpg -crop %[fx:min(w,h)-10]x%[fx:min(w,h)-10]+5+5 out.jpg
OR
convert in.jpg -set foo 100x100+5+5 -crop %[foo] out.jpg

Re: expressions as arguments

Posted: 2015-04-10T08:43:55-07:00
by fmw42
Only a few IM6 distort functions allow computations for arguments. Crop is not one. You need to compute the dimensions first as variables and then use the variables as argument. In unix

Code: Select all

size=`convert -ping in.jpg -format "%[fx:min(w,h)-10]" info:`
convert in.jpg -crop ${size}+5+5 +repage out.jpg
In IM 7, in-line computations will be available for most functions.