IM on OS X: Use mask to split an image

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
antonv
Posts: 2
Joined: 2013-02-27T16:00:48-07:00
Authentication code: 6789

IM on OS X: Use mask to split an image

Post by antonv »

I would like to take an image, apply a checkerboard pattern to it so that the result is two images one having the even squares of the original image + transparency and the other having the odd squares of the original image + transparency.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM on OS X: Use mask to split an image

Post by snibgo »

Make the chequerboard in black and white. Then ...

Code: Select all

convert infile ( chequerboard -negate ) -compose CopyOpacity -composite outfile
... will make one output file. For the other, leave off "-negate".
snibgo's IM pages: im.snibgo.com
antonv
Posts: 2
Joined: 2013-02-27T16:00:48-07:00
Authentication code: 6789

Re: IM on OS X: Use mask to split an image

Post by antonv »

Thank you!

For posterity... this is how you can make a checkerboard:

Code: Select all

convert -size 640x480 pattern:checkerboard -auto-level +level 0,100% checkerboard.gif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM on OS X: Use mask to split an image

Post by fmw42 »

convert -size 640x480 pattern:checkerboard -auto-level +level 0,100% checkerboard.gif
There should be no need for +level 0,100%, which is a no-op (does nothing) in this case. It would only be needed if you want to change the checkerboard to something of less contrast if you use values other than 0 and 100%
Post Reply