I think this might be impossible to do, but I'll ask anyway...
If I have an image (png) with a border/margin around its edges of unknown width and of a specific color, would it be possible to automatically crop the border based on color?
I.E., I have a 300x300px image, with a flower in the center of a white box/background, and then a 100px black margin all around the edges of the white area. I wouldnt know beforehand how wide the black margin is, so I would need to tell imagemagick "trim off all of the black border, leave just the white box/background with flower....
Is there anything like this available through imageMagick???
Please help, thanks...
crop image borders based on color
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: crop image borders based on color
see -trim and -fuzz at http://www.imagemagick.org/script/comma ... ptions.php
convert <image> -trim +repage <result>
convert <image> -fuzz xx% -trim +repage <result>
-fuzz allows the trim to match colors similar to those at the corners
convert <image> -trim +repage <result>
convert <image> -fuzz xx% -trim +repage <result>
-fuzz allows the trim to match colors similar to those at the corners
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: crop image borders based on color
To -trim based on a specific color first add a -border of that color. The -fuzz will then match colors centered on that color.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/