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 size 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

To force a resize without retaining the aspect ratio:

$ convert -resize 800x600\! img.jpg imgs.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

Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. Creative Commons ShareAlike V4.