Page 1 of 1

Problems with -format

Posted: 2012-03-15T06:45:11-07:00
by ndee
Hey everyone,
I am trying to get the image witdth and heigth of an image!
I have googled a lot and found this page: http://www.imagemagick.org/script/identify.php

Identify has an option -format that can give me the height and width of an image. Unfortunately this does not work for me.. Am I doing something wrong?
$ identify -format "%[fx:w/72] by %[fx:h/72] inches" document.png
8.5 x 11 inches

I have a testfile called 000.png and I use this command:
identify -format "%[fx:w/72] by %[fx:h/72] inches" 000.png
My Output is this: w/72] by h/72] inches

My goal is to use this dimensions as variables for later opertations, thats why I need to save them into variables.

Somehow I don't get the dimensions. Does someone know what I am doing wrong? I have installed this imagemagick version: ImageMagick-6.7.6-0-Q16-windows-x64-static.exe


I hope someone can help me!
Thanks in advance,
Andreas

Re: Problems with -format

Posted: 2012-03-15T08:33:56-07:00
by Bonzo
Are you using Windows as it looks like you need to escape the % with another % so it become %%

Re: Problems with -format

Posted: 2012-03-15T10:05:03-07:00
by fmw42
identify -format "%[fx:w/72] by %[fx:h/72] inches" logo:
8.88889 by 6.66667 inches


Works for me on IM 6.7.6.0 Q16 Mac OSX Snow Leopard.

If you are on Windows, then like Bonzo says, escape your % with % as %%

Re: Problems with -format

Posted: 2012-03-15T23:32:59-07:00
by ndee
Thank you for your answers.

Yep, I am under windows and new to batch programming.

I have now written the command as follows: identify -format "%[fx:w/72]% by %[fx:h/72]% inches" 000.png
My output is still the same: w/72][fx:h/72] inches
Other operations work fine, as for example just: identify 000.png

Hmm... I am a bit confused!

Re: Problems with -format

Posted: 2012-03-16T01:23:49-07:00
by Bonzo

Code: Select all

%%[fx:w/72] by %%[fx:h/72]
Some batch file examples on my site may be helpful: http://www.rubblewebs.co.uk/imagemagick/batch.php

Some Imagemagick examples here: http://www.imagemagick.org/Usage/windows/

Re: Problems with -format

Posted: 2012-03-16T01:43:49-07:00
by ndee
Awesome!!
Thanks alot Bonzo! And all others.

This works! I will take a look at your site for sure!!

Once Again! Thanks alot!

Re: Problems with -format

Posted: 2012-03-16T02:27:15-07:00
by ndee
Ok.. I hope this is my last question for this thread!

How can I save the width and height values into a variable?

Here is what I tried:

echo off
identify -format %%w 000.png
set width=%%w
echo %width%

This came out:
1778
%w

Re: Problems with -format

Posted: 2012-03-16T10:43:53-07:00
by fmw42