Auto Trim Empty Space Around an Image

Images made by Paraview tend to have blank spaces around them. It makes it hard to align in TeX documents. Here is a simple way to crop the images and automatically remove those empty spaces.

With the help of ImageMagick, this task is easy:

$ convert image.png -fuzz 1% -trim +repage trimmed.jpg

The -fuzz option allows the trim to be less sensitive to slight color variations in the area you want to trim.

If the image is partially transparent, you may also want to flatten the image before triming:

$ convert image.png -flatten -fuzz 1% -trim +repage trimmed.jpg


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.