Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go

Resize an Image

20190428 To re-scale (resize or reduce the szie of) a photo (or any image) that might be too large for sending by email, for example, or too large to include in a presentation:

$ convert -resize 800x600 img.jpg imgs.jpg

This will resize the image down to a size that will fit within the specified bounds (800x600). Depending on the aspect ratio of the original image, the resulting image will be exactly 800x600, or its width will be 800 or its height 600. If a single size is specified, then either the width or the height is reduced to that.

This can also be done in-place:

$ mogrify -resize 800 img.jpg

A percentage can be specified instead and is generally simpler, retaining the aspect ratio:

$ convert -resize 25% img.jpg imgs.jpg

The following example will maintain the image's aspect ratio (the specified width and height are maximum values). To force a change to the aspect ratio append the geometry with an exclamation point:

$ mogrify -geometry


Copyright © 1995-2019 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware and the author of open source software including Rattle and wajig.
Also the author of Data Mining with Rattle and Essentials of Data Science.