Crop based on color

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kboehme1
Posts: 5
Joined: 2016-12-12T22:43:19-07:00
Authentication code: 1151

Crop based on color

Post 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
Last edited by kboehme1 on 2016-12-13T08:16:22-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop based on color

Post 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
kboehme1
Posts: 5
Joined: 2016-12-12T22:43:19-07:00
Authentication code: 1151

Re: Crop based on color

Post 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.
Post Reply