ImageMagick

· jollygood's blog

#CLI-tools

ImageMagick is a convenient tool for automating image manipulation tasks. As it says on their website1: One of the key features of ImageMagick is its support for scripting and automation.

I discovered ImageMagick recently when I needed a tool to automatically resize images, and I want to share how I use it.

I track an energy meter on an (almost) daily basis. I simply take a photo of the meter and upload the photo to a cloud drive, where I keep the photos for reference. This has been going on for some time, so I have lots of photos and they take up quite a bit of storage space. However, I can read the meter from lower-resolution photos - I don't need all megapixels that my phone's camera produces - so I can save cloud storage space by reducing the size of those photos.

ImageMagick provides the mogrify command to manipulate images in place. I have a script that calls mogrify -resize "1024x1024" <PHOTO.jpg> on my energy meter photos. This command resizes the image resolution to max 1024 pixels per side, while maintaining the aspect ratio. Typically this produces images of size 768x1024 or 1024x768.

With my current phone camera settings this reduces storage size by 90% from ~2MB to ~200kB. That is, without ImageMagick my cloud drive would use ~10x as much space for the energy meter photos.

That is how I use ImageMagick at the moment. I like to make scripts for routine tasks that I do on a regular basis, and CLI tools like ImageMagick are very convenient for this purpose.