Mask and tile

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
tantrum
Posts: 8
Joined: 2020-01-12T08:19:09-07:00
Authentication code: 1152

Mask and tile

Post by tantrum »

Hi--

I have this example from the ImageMagick documentation where it puts a tile against the white areas of the incoming image. This works fine. mask_bite is an image with black background and white image on it.

convert mask_bite.png -size 100x100 tile:tile_disks.jpg -compose Multiply -composite out.png

--- my question is I am trying to take an image that's all black on a transparent background and apply this tile against that. It works fine if my black image is white, but can't figure out how to do for a black image.

thanks

User avatar
fmw42
Posts: 26273
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mask and tile

Post by fmw42 »

Please post your images to some free hosting service and put the URLs here. We need to see what is happening with those images. Also always provide your ImageMagick version and platform when asking questions as syntax may vary.

tantrum
Posts: 8
Joined: 2020-01-12T08:19:09-07:00
Authentication code: 1152

Re: Mask and tile

Post by tantrum »

Thanks, here is a sample black image on transparent background. https://ibb.co/XyVYKQQ

the tile image I got from here: https://www.imagemagick.org/Usage/images/tile_disks.jpg

So trying to figure out command to tile it against the black image, just like that other command does with the white.

Running on OSx . Version: ImageMagick 7.0.9-14 Q16 x86_64 2020-01-06

Thanks,

User avatar
fmw42
Posts: 26273
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mask and tile

Post by fmw42 »

This works for me on IM 7.0.9.18 Q16 Mac OSX Sierra

Code: Select all

magick blackontransparent.png -size 300x87 tile:tile_disks.jpg +swap -compose over -composite out.png

tantrum
Posts: 8
Joined: 2020-01-12T08:19:09-07:00
Authentication code: 1152

Re: Mask and tile

Post by tantrum »

Thanks for the quick response! I tried, the script, but I didn't describe well what I'm trying to do. I'm trying to do the opposite-- so I want the tile to show on anything Black on the image and keep the transparency.

User avatar
fmw42
Posts: 26273
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mask and tile

Post by fmw42 »

This works for me. It is one way to do it. Save the alpha channel and use it after the tiling.

Code: Select all

magick blackontransparent.png \
\( +clone -alpha extract +write mpr:alpha +delete \) \
-size 300x87 tile:tile_disks.jpg -colorspace sRGB -compose over -composite \
-alpha off mpr:alpha -compose copy_opacity -composite \
out.png

tantrum
Posts: 8
Joined: 2020-01-12T08:19:09-07:00
Authentication code: 1152

Re: Mask and tile

Post by tantrum »

brilliant. thanks that works perfectly.

Post Reply