Using -extent with set amount

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
Swillys
Posts: 3
Joined: 2012-11-16T03:47:08-07:00
Authentication code: 6789

Using -extent with set amount

Post by Swillys »

I'm trying to use the extent command to increase the canvas height by a set amount, when the image height is variable.

The below would ideally increase the canvas height by 100 pixels each time regardless of the original height of the image:

convert in.jpg -resize 595 -extent 595x([Photo.PixelYDimension]+100) out.jpg

The [Photo.PixelYDimension] is part of the program I'm using, which will correctly retrieve the height of the image. The above command will shift the image 100 pixels left. Is there a clever way to use brackets for this or a workaround?

Any help much appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using -extent with set amount

Post by fmw42 »

You cannot do that in general with IM6. You need to save the argument from the other program into a shell variable and then do some computation with it. Then pass the shell argument to the IM command.

see
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/script/fx.php

IM 7 (in alpha development) will be much more conducive to doing computations inline.
Post Reply