fill with tile:Image.png - retain Transparent Background

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
whidbeyeagle
Posts: 4
Joined: 2013-11-01T15:27:11-07:00
Authentication code: 6789

fill with tile:Image.png - retain Transparent Background

Post by whidbeyeagle »

What is the easiest way to fill a opaque color area of an image that has a transparent background with a tile:Image.png and retain the transparent background.
I have no problem using convert fill to change the area to any color.
Also I can convert tile:Image.png compose and composite but that fills in the transparent background.
I have also tried doing with a mask without success.
Thank you
Wayne
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fill with tile:Image.png - retain Transparent Background

Post by fmw42 »

One way is to tile out a new image of the size of the area you want to replace, then composite the tiled image over that region (assuming you are talking about a rectangular area.

If might be helpful to see the image you want to start with in order to understand your problem better.

Also please identify your IM version and platform.
whidbeyeagle
Posts: 4
Joined: 2013-11-01T15:27:11-07:00
Authentication code: 6789

Re: fill with tile:Image.png - retain Transparent Background

Post by whidbeyeagle »

I am using Version: ImageMagick 6.8.4-8 2013-04-09 Q16
My base image has a transparent background
Image

I would like to replace the black with this swatch image below and retain the transparent background and tile the image to fit if needed

Image

I am not able to create the mask needed in IM so the one you see below I created manually

Image

I am able to execute the following command to create my final image below
convert green_swatch_200X200.png base_black_mask2.png -alpha off -compose copy_opacity -composite final_image.png

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

Re: fill with tile:Image.png - retain Transparent Background

Post by fmw42 »

try this (it extracts the alpha channel from the transparent base image)

convert green_swatch_200X200.png \( base_image.png -alpha extract \) -compose copy_opacity -composite result.png
Last edited by fmw42 on 2013-11-02T15:09:11-07:00, edited 1 time in total.
whidbeyeagle
Posts: 4
Joined: 2013-11-01T15:27:11-07:00
Authentication code: 6789

Re: fill with tile:Image.png - retain Transparent Background

Post by whidbeyeagle »

Fred
It worked perfect
:D
Thank you very much for the assist

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

Re: fill with tile:Image.png - retain Transparent Background

Post by fmw42 »

If you have a base tile, you do not need to create the tiled image separately. You can combine it all in one command.


convert \( -size 200x200 tile:tree.gif \) \( base_image.png -alpha extract \) -compose copy_opacity -composite show:
whidbeyeagle
Posts: 4
Joined: 2013-11-01T15:27:11-07:00
Authentication code: 6789

Re: fill with tile:Image.png - retain Transparent Background

Post by whidbeyeagle »

Fred

You are really making my day

8)

Wayne
Post Reply