Darek Kay's picture Darek Kay

Create uniform album art images with ImageMagick

Call me old-fashioned, but despite using streaming services, I like to own the music I listen to. This also means I'm handling album cover images that come in different sizes and ratios. Recently I wrote a script to unify the image size:

  • The base image size should be 500×500 px
    • E.g. 1000×1000 → 500×500
  • The image should be a square
    • E.g. 1000×900 → 500×500
  • The image should not scale up if any side is smaller than 500 px
    • E.g. 450×500 → 450×450

Visualization for resizing a 1000×750 px image to 500×500 px

ImageMagick is my tool of choice for image manipulation. First, let's transform the image into a square:

convert -resize 1:1\!\> input.jpg output.jpg
  • 1:1 is the target aspect ratio (square)
  • ! ignores the original aspect ratio
  • > shrinks the larger side

Next, let's resize the image to 500×500 px, unless the image is smaller:

convert -resize 500x500\> input.jpg output.jpg

Finally, we can combine both commands, as ImageMagick supports multiple -resize arguments:

convert -resize 1:1\!\> -resize 500x500\> input.jpg output.jpg

Note: On Windows, we need to switch the escape character from \ to ^:

convert -resize 1:1^! -resize 500x500^> input.jpg output.jpg

Related posts

Want to leave a comment?

Join the discussion at Twitter or Mastodon. Feel free to drop me an email. 💌

Create uniform album art images with ImageMagick