Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Remove Black Borders From An Image With ImageMagick

Making a new image:

Code

magick input.jpg -fuzz 7% -trim output.jpg

Updating an existing image

Code

magick mogrify -fuzz 7% -trim +repage image.jpg

References

  • - https://www.imagemagick.org/script/command-line-options.php#trim

    - https://www.imagemagick.org/script/command-line-options.php#fuzz

    - https://stackoverflow.com/a/55755082/102401 - The exmaple on this page is only working once for me. If it's re-run over the same image it turns everything white and throws an error.

    - https://imagemagick.org/script/convert.php

    - https://imagemagick.org/script/mogrify.php