[Solved] Remove cutout residue (transparent background picture)

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
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

[Solved] Remove cutout residue (transparent background picture)

Post by Rye »

So, as so often, when someone uses any app to remove the background (mostly with the magic wand tool), you might end up with this:

Image

As it is plain to see:
Around the contours, there is a white "residue", that couldn't be removed with the programs tool.

Question:

Can imagemagick help here ?
(I heard about a -trim option, but that only seems to be appropriate if the background is entirely colored ?)

- Thanks in advance.
Last edited by Rye on 2018-11-07T09:58:04-07:00, edited 1 time in total.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove cutout residue (transparent background picture)

Post by fmw42 »

try a little anti-aliasing of the alpha channel as follows:

Code: Select all

convert image.png -channel a -blur 0x1 -level 50x100% +channel result.png
Adjust the blur x1 value as desired.
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Remove cutout residue (transparent background picture)

Post by Rye »

Works perfectly !

The blur variable changes the way the edges are smoothed ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove cutout residue (transparent background picture)

Post by fmw42 »

Rye wrote: 2018-11-07T09:03:32-07:00 The blur variable changes the way the edges are smoothed ?
Yes, larger blur value than 1 (0x1) will smooth more and you will lose more edge data. You probably can reduce the 1 to 0.5 as about the minimum that you can detect. But it may be too small to make a change. Try different values and see what looks best to you.
Post Reply