Page 1 of 1

Crop based on color

Posted: 2016-12-12T22:47:21-07:00
by kboehme1
Image

How would I crop one of the above images on the pink border (remove pink border as well)? I split the gif into individual frames as well. Seems like it should be easy but I cant get it working.

Version: ImageMagick 6.9.0-3 Q16 x86_64 2015-01-09 http://www.imagemagick.org
OS: MacOSX

Re: Crop based on color

Posted: 2016-12-12T23:57:29-07:00
by fmw42
What is your IM version and platform? Please always provide that, since syntax differs.

In Unix syntax, try this

Code: Select all

convert pillAnim.gif[0] \
\( +clone -fuzz 20% -fill white +opaque "rgb(255,108,115)" -fill black +opaque white \
-morphology smooth octagon:1 -morphology erode octagon:1 \
-fuzz 0 -fill black -draw "color 0,0 floodfill" \) \
-alpha off -compose copy_opacity -composite -fuzz 10% -trim +repage \
result.png

Re: Crop based on color

Posted: 2016-12-13T08:23:26-07:00
by kboehme1
fmw42 wrote:What is your IM version and platform? Please always provide that, since syntax differs.

In Unix syntax, try this

Code: Select all

convert pillAnim.gif[0] \
\( +clone -fuzz 20% -fill white +opaque "rgb(255,108,115)" -fill black +opaque white \
-morphology smooth octagon:1 -morphology erode octagon:1 \
-fuzz 0 -fill black -draw "color 0,0 floodfill" \) \
-alpha off -compose copy_opacity -composite -fuzz 10% -trim +repage \
result.png
Thank you very much that works great! For some images it looks like I will need to tweak the fuzz factor a bit. Also edited my question.