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
Problems with -format
Re: Problems with -format
Are you using Windows as it looks like you need to escape the % with another % so it become %%
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with -format
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 %%
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
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!
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
Code: Select all
%%[fx:w/72] by %%[fx:h/72]
Some Imagemagick examples here: http://www.imagemagick.org/Usage/windows/
Re: Problems with -format
Awesome!!
Thanks alot Bonzo! And all others.
This works! I will take a look at your site for sure!!
Once Again! Thanks alot!
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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems with -format
It should be explained in http://www.imagemagick.org/Usage/windows/