Trimming an image using alpha

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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Recent versions of ImageMagick account for the alpha channel when trimming. Perhaps you are using an older version of ImageMagick or perhaps you need to increase the fuzziness (e.g. -fuzz 40%).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Chances are your image does not have a uniform background color which stops the trimming from working as you had hoped. You might be able to eliminate some noise with a median filter first and see if that makes a difference.
RetroJ
Posts: 108
Joined: 2006-10-25T08:12:50-07:00

Post by RetroJ »

ggambett wrote: The alpha channel is correctly empty in the left zone. The color channels do have color data in some of the transparent areas, as shown with -separate.

There are a few pixels in column 0 whose alpha value differs, as you can see with:

Code: Select all

convert upgrade_sound06.png -crop 1x600 txt: | less
You can overcome this by doing:

Code: Select all

convert upgrade_sound06.png -fuzz 1% -trim +repage out.png
Post Reply