DETECT IMAGE SIZE

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
foruforewer
Posts: 26
Joined: 2011-02-08T04:37:21-07:00
Authentication code: 8675308

DETECT IMAGE SIZE

Post by foruforewer »

I want to detect input image size can anyone guide?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: DETECT IMAGE SIZE

Post by fmw42 »

convert image -format "%wx%h" info:
or
identify -format "%wx%h" image

gives the width x height


convert image -format "%b" info:
or
identify -format "%b" image

gives the filesize


see string formats at http://www.imagemagick.org/script/escape.php
foruforewer
Posts: 26
Joined: 2011-02-08T04:37:21-07:00
Authentication code: 8675308

Re: DETECT IMAGE SIZE

Post by foruforewer »

thank you very much
foruforewer
Posts: 26
Joined: 2011-02-08T04:37:21-07:00
Authentication code: 8675308

Re: DETECT IMAGE SIZE

Post by foruforewer »

Next que.. after getting height and width, i want to store them in some variable and add 100, so i had tried further as below but not working. can you please guide in this?

Code: Select all

set ht=identify -format "%h" im1.png
set wd=identify -format "%w" im1.png
set /A ht=ht+100
set /A wd=wd+100
set "sz=%ht%x%wd%"
convert -size sz xc:black output.png
but it wont working at
1) storing in ht,wd
2) defining concatenated string by sz
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: DETECT IMAGE SIZE

Post by fmw42 »

on unix

newht=$((ht+100))

or you can compute it from scratch

newht=`convert image -format "%[fx:h+100]" info:`
or
newht=$(convert image -format "%[fx:h+100]" info:)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: DETECT IMAGE SIZE

Post by anthony »

IMv7 "magick" command will allow you to do all this in the one command line (or file script).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply