I've been trying to get this to work all afternoon, I thought it would be simple but I can't get it to work

I have a .png mask, the black part of the mask indicates the area I want from a transparent .gif
First I make a tile of images and save it in a .gif with transparency:
Code: Select all
convert -background None -size 373x280 tile:heart.png tile.gif

Then I have this mask:

The black area needs to be filled with the heart tiles, while the rest needs to remain transparent.
But this is what happens:
Code: Select all
convert tile.gif mask.png -compose CopyOpacity -composite -matte output.gif

So it's almost good, but the black color needs to be transparent. I know I can remove it with -transparent but if the tile.gif happens to have black in it it would remove too much. Can someone help me extract a part from a transparent gif and save it in a transparent png?