Home > Wiki > ImageMagick Articles

All articles are licensed under CC0 1.0 making them public domain.

Scaling an image #

Last updated February 2021

Maintaining Aspect Ratio

Define a single dimension and leave the other out in the option: [width]x[height].

  • Width defined - magick input.jpg -scale 500x input-w500.jpg
  • Height defined - magick input.jpg -scale x500 input-h500.jpg

Custom Width/Height

Use -scale [width]x[height] to scale to a custom size.

Bilinear / Nearest Neighbor

The -interpolate [type] option is used to define the method used to scale.

  • bilinear - a double linear interpolation of pixels (the default)
  • nearest-neighbor - the nearest pixel to the lookup point (rounded function)

I have only included the most common types, you can find all types within the ImageMagick documentation (external).


Trashing an image #

Last updated February 2021

Making an image look subtly bad can be appropriate in some cases, like avatars for Steam accounts.

Steps

  1. Convert the image to a JPEG and give it 20% quality:

    magick -i image.png -quality 20 badimage1.jpeg
  2. Scale the image down to a fifth of its size:

    magick -i badimage1.jpeg -resize 20% badimage2.jpeg
  3. Scale it back up to the original size:

    magick -i badimage2.jpeg -resize 500% finalbadimage.jpeg

More Options

There's a lot more you can do with ImageMagick to make images look worse, consult the documentation and screw around with any effect you think sounds bad.