Log in

View Full Version : Mask Transparency - are gif's allowed?


pinkshiro
27th August 2010, 06:27
I'm trying to apply a logo to the bottom right corner of a video using avisynth.

If the logo is a png format, the mask works great. Gif on the otherhand, just won't show up when I apply the following code:

#Logo overlay
Logo=ImageSource("logo.gif", end = 1, use_DevIL=false).ConvertToRGB32()

#Create a mask for the logo
LogoMask = ImageReader("logo.gif",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")

#Logo width and height
Logowidth = Width(Logo)
Logoheight = Height(Logo)

#Add in overlay
FinalVideo = Overlay(FinalVideo, Logo, (W-Logowidth)-20, (H-Logoheight)-20, mask=LogoMask)

But works fine when it's a PNG.

Do I have an issue with my code above? Or do I need to ensure the gif is saved out a particular way?

Hopefully someone can help me out with some advice, cheers.

Wilbert
27th August 2010, 18:45
Your script doesn't make any sense and doesn't produce output. I guess you only posted a part of it. You also don't need to load your logo.gif twice.

Try

#Logo overlay
Logo=ImageSource("logo.gif", end = 1, use_DevIL=false).ConvertToRGB32()

#Create a mask for the logo
LogoMask = ImageReader("logo.gif",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")

return LogoMask

Is the mask showing up properly? If not, your logo.gif doesn't have an alpha channel.

Didée
27th August 2010, 19:36
GIF's never have an alpha channel. They have an 8bit palette, and one of the 256 entries can be marked as being "transparent".

Make sure that the actual value of the transparent color is unique in the palette, isolate and transform it with mt_lut, then use that as mask or alpha layer.

pinkshiro
27th August 2010, 21:09
Your script doesn't make any sense and doesn't produce output. I guess you only posted a part of it. You also don't need to load your logo.gif twice.

Try

#Logo overlay
Logo=ImageSource("logo.gif", end = 1, use_DevIL=false).ConvertToRGB32()

#Create a mask for the logo
LogoMask = ImageReader("logo.gif",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")

return LogoMask

Is the mask showing up properly? If not, your logo.gif doesn't have an alpha channel.

Thanks. I made an assumption that it would be obvious that this was only a partial script. My apologies...

Didée, thank you for your feedback. Appreciate it.