Heuristic
Heuristic

Reputation: 5341

imagemagick: how to get image size after resize?

I'm resizing my image using imagemagick, however, I'm not specifying the exact size:

convert $filename -resize 1080000@ -quality 100 $reduced_filename

it's resized within a bound, now the problem is, after resize, the size in the EXIF is no longer correct, and I don't have a clue of calculating the new size (e.g. percentage resize can let me calculate new size based on percentage).

So is there a way to get image size after resizing?

Thanks!

Upvotes: 0

Views: 2177

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207778

Like this...

First create a start image 1024x768:

convert -size 1024x768 xc:black start.jpg

Now resize, and output new size info in one fell swoop:

convert start.jpg -resize 50% -format "%wx%h" -write info: result.jpg
512x384

Upvotes: 3

GeeMack
GeeMack

Reputation: 5395

You can use ImageMagick's "convert" command to access the image dimensions with a command like this...

convert $filename -format "%[w]x%[h]" info:

Upvotes: 3

Related Questions