Steve's Photography Tips: Resizing Photos with ImageMagick

Glass Beach on Kauaʻi

Waves, sand, clouds, and a beautiful blue sky at Glass Beach near ʻEleʻele on the island of Kauaʻi in Hawaiʻi, in a photo reduced in size using ImageMagick.

Waves, sand, clouds, and a beautiful blue sky at Glass Beach near ʻEleʻele on the island of Kauaʻi in Hawaiʻi, from our 2018 Kauaʻi trip. As you may remember from the trip report, this was the last beach that we visited during our trip, and it was a great way to end. This photo was resized with ImageMagick to make it load faster on this webpage. What does that mean? Read on!

The Wonders of ImageMagick

These days, websites are all about speed. And one of the main factors affecting the loading speed of a webpage is the size of any images on the page. There are different ways to handle this, including a few different plugins for Wordpress.

I prefer to resize the photos for the Burnsland website myself. And I also like to add a Burnsland watermark to the photos as well. In addition, I create a title card for each post and also a Pinterest graphic. That may all sound like a lot of extra work, but it isn’t. Thanks to setting up a few things ahead of time, I can create all of those different versions of the photo with just a couple of clicks.

All of this is accomplished using a remarkable software solution known as ImageMagick. This open-source software can do many, many different things, and I admittedly only use a few of them. But those few save me quite a bit of time.

For starters, you will need to download and install ImageMagick from its website. Also at the website are instructions on how to do most of the tasks that ImageMagick can handle if you need some more information. Also, note that I use Windows, so these instructions will be more Windows-based. However, you Mac people should be able to figure out something similar.

Once you have ImageMagic installed, you are all set to go for creating your different photo versions. On my computer, I have created different .bat files to run these. You can create those using Notepad or another text editor, and save it as a .bat file instead of as a .txt file. I put the photo that I want to resize in the same folder as the .bat file. I then just double-click the .bat file and it does the rest. Pretty cool.

Resizing a photo

If you want to resize a photo to certain dimensions, here is some simple code to use. For photos here on the website, I like to keep them to a maximum width of 1920 pixels. That is still larger than they actually need to be, but it is much better than a full 20 megapixel photo.

Here is the code for that operation:

magick convert *.jpg -strip -interlace Plane -resize "1920x1280>" -quality 85 -modulate 100,130,100 -set filename:fname %%t_small +adjoin %%[filename:fname].jpeg
magick mogrify -path wm -format jpg -interlace Plane *.jpeg
DEL *.jpeg

Now, here is an explanation of what each part does.

  • magick: loads the ImageMagick program

  • -strip: Strips the data from the photo. This includes camera settings, date, location data, and so on. That information can be good to have, but it adds to the size of a photo.

  • -interlace: Changes the file from a progressive to an interlaced photo. See this article for an explanation of interlaced images.

  • -resize “1920x1280>”: Resizes the image to a maximum width of 1920 pixels or a maximum height of 1280 pixels, whichever is larger. The “>” character indicates not to resize images that are smaller than 1920x1280.

  • -quality 85: A quality setting. The higher the quality, the larger the image. The lower the quality, the worse the image looks.

  • -modulate 100,130,100: I have found that interlacing a photo changes its color saturation somewhat. This command compensates for that. The three numbers are hue, saturation, and lightness in percentages. So this increases the saturation while leaving the hue and lightness as they are.

  • -set filename (and following): I like to save everything as a new name to keep the different versions separated. This adds “_small” to the end of the filename.

  • mogrify: Changes an image and overwrites the intial image. In this case I use it to move the image to the subfolder “wm” (set by the -path command). Also at this time, the file extension is changed from .jpeg to .jpg.

  • DEL *.jpeg: This is not actually part of the ImageMagick commands, but it deletes the .jpeg file in the main folder, leaving the original file (which was a .jpg file) in the folder.

That all may sound confusing, but it really isn’t all that bad. And once you get everything set like you want it, you don’t have to change a thing.

The Glass Beach photo above was resized using the exact code that is up above, and I only had to click on the batch file to do it. The original file that I exported out of Aurora HDR was 2.02 MB in size, with dimensions of 4608 pixels by 3072 pixels. The photo that I uploaded here after ImageMagick did its thing is only 522 KB, with dimensions of 1920 pixels by 1280 pixels. That is a savings of 75% in disk space, which obviously makes the photo load much faster.

Also, one more note: Running the .bat file will change every JPG file in that folder. I have a dedicated folder just for resizing, and the only thing in it are the .bat file, the photo that I want to resize, and the subfolder for the resized photos. However, if you want to resize several photos at once, just put all of them in your folder and run the .bat file, and all of them will be converted.

More Photo Tips

It has been a while since I have added any new posts of Steveʻs Photography Tips. And while this one does not strictly involve the taking of a photo, it can be very helpful if you use a website to display the photos you have taken. After all, photos are even better when you share them with others.

Next time around, we will look at adding a watermark to a photo, also using ImageMagick! Stay tuned for that helpful tip!

Bible Verse

Do not neglect to do good and to share what you have, for such sacrifices are pleasing to God. - Hebrews 13:16

About the Photo

It was an almost perfect day that day, as you can see by the sky and the few clouds. So there really was not much special involved in taking this photo. Just point and shoot, and let Godʻs nature do the rest.

As I mentioned above, I used Aurora HDR to process this one. Even with the beauty that was already there, Aurora gave it an even more eye-catching look.

Photo: A single Raw exposure, processed in Aurora HDR. Read more about photography tips, photo software, camera gear, and more at Steve’s Photography Tips.
Camera: Olympus OM-D E-M10
Lens: Olympus 14-42mm IIR
Date: July 11, 2018
_Location: _ Glass Beach, ʻEleʻele, Hawaiʻi