Tuesday, September 25, 2018

for simply converting and resizing

It's been about five years since I first mentioned ImageMagick (see: "resize an avatar"). Lately, I've kinda "rediscovered" it, and I've found its tools to be quite convenient for resizing images and for converting images to different formats. I haven't actually done much with ImageMagick besides those types of easy conversions, but there are many, many other things this software can do.

The magick and convert commands require the imagemagick package, as they are part of the ImageMagick suite of tools. For simple procedures like the ones being discussed here, either magick or convert will work. However, note the following about the convert command, from man imagemagick:

convert
 

Backwards compatiblity [sic] for ImageMagick version 6 "convert". Essentually [sic] an alias to a restrictive form of the "magick" command, which should be used instead.

FWIW, imagemagick is currently at version 6.9.7.4 in Debian Stable and in Ubuntu 18.04, and it's at version 7.0.8.12 in Arch. In any case, I think it's ok to use either one of the two commands. [Edit: Looks like the magick command can be used in the imagemagick version 7.0+ found in the Arch repos, but it doesn't exist in the 6.9 version found in the Stable repos; with that version, the convert command must be used.]




converting and resizing

To convert from jpg to png, run magick [oldfilename] [newfilename], making sure to change the file extension from .jpg to .png. For example:

$ magick /home/user1/image.jpg /home/user1/image.png

Here's an example of resizing an image to 1366x768 and also converting it from jpg to png, using magick:

$ magick /home/user1/image.jpg -resize 1366x768! /home/user1/image.png

(The "!" forces the conversion to the specified dimensions, ignoring aspect ratio.)

Doing the same thing using convert:

$ convert /home/user1/image.jpg -resize 1366x768! /home/user1/image.png


For more info, see man imagemagick, man magick, man convert, convert -help, etc.

Also see:
https://www.lifewire.com/convert-linux-command-unix-command-4097060
http://www.imagemagick.org/script/index.php


No comments: