Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

unix - Can ImageMagick return the image size?

I'm using ImageMagick from the command line to resize images:

convert -size 320x240 image.jpg

However, I don't know how to determine the size of the final image. Since this is a proportional image scale, it's very possible that new image is 100x240 or 320x90 in size (not 320x240).

Can I call the 'convert' command to resize the image and return the new image dimensions? For example, pseudo code:

convert -size 320x240 -return_new_image_dimension image.jpg   // returns the new resized image dimensions
question from:https://stackoverflow.com/questions/1555509/can-imagemagick-return-the-image-size

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could use an extra call to identify:

convert -size 320x240 image.jpg; identify -format "%[fx:w]x%[fx:h]" image.jpg

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...