Tag Archives: ImageMagick

Using ImageMagick to Prepare Images for Upload on Windows

A few years ago, I wrote a short post detailing how to automatically rotate, resize, and strip EXIF data from the images that I upload to this website.

At the time, I was working on Linux, so the instructions in that article target Linux-based operating systems. Over the intervening years, I’ve switched back to running Windows 10 on my home laptop, so I figured it was time to update my original instructions to target my new platform of choice.

Installing ImageMagick

One of the reasons that I now run Windows at home (or at least one of the reasons why I don’t mind running Windows at home as much as I once did) is that the Windows command line experience has improved by leaps and bounds over the past few years.

For command line goodness in Windows, I run PowerShell inside of ConEmu, and I use Chocolatey to install and manage command line utilities.

Luckily ImageMagick is available for Windows, and you can install it via Chocolatey as follows:

$ choco install imagemagick.tool

Note that I’m purposefully installing the portable release here, because it includes all of the command line tools in addition to the main ImageMagick GUI application.

The installer modifies your $PATH variable, so you’ll have to run refreshenv once it’s complete.

Modifying Images with Mogrify

As in the original tutorial, I still use mogrify to prepare my images for upload.

Start by copying the images that you want to use into a temporary folder. Mogrify is going to modify them in place, so you definitely don’t want to work against the original images.

Next, run the following command from PowerShell/cmd in the temporary folder:

mogrify -auto-orient -resize 584x438 -strip -quality 85% *.jpg

This command will re-orient and resize your images, strip any EXIF data from them, and re-encode them as jpegs at 85% quality. The full manpage for mogrify can be found on the ImageMagick website.

Leave a Comment

Filed under Software