Trim image borders by imagemagick
Contents
When converting image format from png to jpeg, imagemagick (convert
command)add margin border with bold black color automatically.
Environment
- MacOS Monterey 12.0, M1 Apple silicon
- Version: ImageMagick 7.1.0-12 Q16-HDRI arm
Problem
Getting screenshot by Command + Shift + 5
in OSX, it allows to get a screenshot for a specific window like:
Above image contains transparent background. Converting .png to .jpg by imagemagick, it generates image border in black color that I do not expect.
|
|
Solution
For removing margins, add options of -trim
, -fuzz
and -border
to convert
command
|
|
- -fuzz distance : colors within this distance are considered equal
- -trim : trim image edges
- -border geometry : surround image with a border of color