How to Resize Smaller Images in ImageMagick?

When batch processing images, you often want to enlarge smaller images to a standard size without accidentally shrinking or distorting your larger files. ImageMagick handles this perfectly using a specific conditional geometry flag (<) within the convert or magick command. This article will show you the exact syntax needed to upscale only the images that fall below your target dimensions, preventing any unwanted resizing of larger assets.

The Conditional Resize Command

To instruct ImageMagick to only upscale an image if its dimensions are smaller than your target size, you append a less-than sign (<) to the geometry argument.

Here is the standard command structure:

magick convert input.jpg -resize "1920x1080>" output.jpg

Note: In newer versions of ImageMagick (v7+), the convert command is deprecated in favor of the unified magick command, though magick convert still works for backwards compatibility.

Why the Backslash or Quotes are Necessary

In most terminal environments (like Linux Bash, macOS Zsh, or Windows PowerShell), the < character is a special operator used for input redirection. If you type it plainly, your terminal will throw a syntax error.

To prevent this, you must “escape” the character or wrap the entire dimension string in quotes. Depending on your operating system, choose one of the following methods:

magick convert input.jpg -resize "800x600<" output.jpg
magick convert input.jpg -resize 800x600\< output.jpg

How ImageMagick Evaluates the Conditions

ImageMagick looks at both the width and the height of your input image and compares them to your target dimensions: