How to resize image (including animated gif) using Image magick convert

Imagemagick convert can be used to resize and image (including animated gif). Here are some scenarios where convert can be used to change size of an image. For these commands to work Imagemagick need to be installed on your Mac or Linux.

Resize image to specific width

Resize image to width=300 and take height automatically in same proportion

$ convert image1.gif -resize 300x image2.gif

Resize image to specific height

Resize any image to height=200 and take width automatically in same proportion

$ convert image1.gif -resize x200 image2.gif

Resize image to fit in specific width and height container

Resize image to width=300 height=200. To maintain aspect ratio convert will take height and width such that target image remains with in 300×200. In target one of height or width may be lower than specified width and height.

$ convert image1.gif -resize 300x200 image2.gif

Resize image to percentage

Resize image to 50%.

$ convert image1.gif -resize 50% image2.gif

Resize animated gif

To handle animated gif first run convert with -coalesce. Then regular conversion methods will apply.

$ convert image_animation_1.gif -coalesce coalesce.gif
$ convert coalesce.gif -resize x200 image2.gif
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments