expressions as arguments

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

expressions as arguments

Post by GreenKoopa » 2015-04-10T06:33:09-07:00

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

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: expressions as arguments

Post by fmw42 » 2015-04-10T08:43:55-07:00

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.

Post Reply