Using Mask with images

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
MrsCalahan
Posts: 9
Joined: 2009-05-13T01:28:22-07:00
Authentication code: 8675309

Using Mask with images

Post by MrsCalahan »

Hi,

I try to create an Imagemask on this way: http://www.imagemagick.org/Usage/masking/#masks

The first step

Code: Select all

convert -size 100x100 xc:none -stroke black  -fill steelblue  -strokewidth 1 -draw "circle 60,60 35,35" -strokewidth 2 -draw "line 10,55 85,10" drawn.png
works

The second step

Code: Select all

convert drawn.png -alpha extract  mask.png
throws an error:
convert: UnrecognizedAlphaChannelType `extract'.
Does anybody know whats the problem?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Using Mask with images

Post by el_supremo »

That suggests that you are using an older version of IM which does not support "-alpha extract".
Which version are you using?

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using Mask with images

Post by fmw42 »

on older systems, you can replace

convert image -alpha extract resultimage

with

convert image -channel a -separate +channel -negate resultimage
MrsCalahan
Posts: 9
Joined: 2009-05-13T01:28:22-07:00
Authentication code: 8675309

Re: Using Mask with images

Post by MrsCalahan »

Hi,

yes it was an old IM Version. With the new Version ImageMagick 6.7.3-8 2011-11-23 Q16 -aplpah extract works.

I solved my problem like this:

Code: Select all

### creat a maske 
convert -size 100x100 xc:none -draw "circle 40,80 60,60" mask_shape.png

### use the mask on an image an create the result image
composite -compose Dst_Out -gravity center mask_shape.png  icon.png -alpha Set result.png 
Thanks for your help!
Post Reply