Dave's Brain

Browse - Programming Tips - How can I get the width and height of an image for use a program or script?

Date: 2016apr26
Product: ImageMagick
Keywords: magic

Q.  How can I get the width and height of an image for use a program or script?

A.  Use identify from ImageMagick

identify -format '%w' THE_IMAGE.jpg identify -format '%h' THE_IMAGE.jpg
This will just display the width and height. In a bash script:
width=$(identify -format '%w' THE_IMAGE.jpg) height=$(identify -format '%h' THE_IMAGE.jpg)

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.