ImageMagick change image width and height
I am using ImageMagick to resize image resolution by using below command-line option convert abc.png -set units PixelsPerInch -density 75 abc_a.png I am in need of this: if any images has more than 300 width OR more than 100 height, I want to convert it to width 300 width and 100 height, with changing above dpi (i.e. 75dpi). Can any one help me on this? If you are on Linux/OSX, you can get the image dimensions like this: identify -format "%w %h" input.jpg So, if you want the width and height in variables w and h , do this: read w h < <(identify -format "%w %h" input.jpg) Now you can test the