-resize using image size information

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
josephs
Posts: 40
Joined: 2014-04-08T10:13:43-07:00
Authentication code: 6789

-resize using image size information

Post by josephs »

I have successfully resized the image without preserving aspect ratio using the following:

-resize 800x400!

...but I am unable to get any result using the image size information instead. There is no change in image using this:

-resize "%%[fx:w]"x"%%[fx:w/2]!

Is this a syntax issue?

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

Re: -resize using image size information

Post by fmw42 »

No, IM 6 does not support inline fx computations for any geometry (other than in -distort via -define distort:viewport). You need to find the width and height in a separate command from for example

Code: Select all

width=`convert image -format "%w" info:`
Then use the variable in the -resize.

IM 7 is supposed to allow what you are trying to do.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -resize using image size information

Post by snibgo »

-resize "%%[fx:w]"x"%%[fx:w/2]!
As Fred says, this isn't valid syntax in IM v6. But you can use percentages:

Code: Select all

-resize 100%%x50%%
(Doubling the % is required for Windows BAT syntax.)
snibgo's IM pages: im.snibgo.com
Post Reply