# Tk Images - Transparency

**URL:** <https://www.ruby-forum.com/t/tk-images-transparency/188254>\
**Category:** Ruby\
**Created:** [May 8, 2010, 3:52pm UTC](https://www.ruby-forum.com/t/tk-images-transparency/188254 "2010-05-08T15:52:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcubed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jcubed](https://www.ruby-forum.com/u/jcubed)\
**Post date:** [May 8, 2010, 3:52pm UTC](https://www.ruby-forum.com/t/tk-images-transparency/188254/1 "2010-05-08T15:52:30Z")

</div>

I’m making a game with Ruby and Tk, but the transparency in the .gif  
images are not showing through in the program, the graphics are instead  
filled with white. I’m not sue if Tk can handle transparencies, but if  
there is an option or a way I have to make the graphics, that would be  
much easier than creating a background for each graphic, for each  
background.

Any help, links, or code would be extremely appreciated.

---

<div class="post-metadata">

**Author:** ![jcubed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jcubed](https://www.ruby-forum.com/u/jcubed)\
**Post date:** [May 8, 2010, 6:53pm UTC](https://www.ruby-forum.com/t/tk-images-transparency/188254/2 "2010-05-08T18:53:24Z")

</div>

On Sat, May 8, 2010 at 7:52 AM, Jesse J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Â I’m making a game with Ruby and Tk, but the transparency in the .gif  
> images are not showing through in the program, the graphics are instead  
> filled with white. I’m not sue if Tk can handle transparencies, but if  
> there is an option or a way I have to make the graphics, that would be  
> much easier than creating a background for each graphic, for each  
> background.
> 
> Any help, links, or code would be extremely appreciated.

This should help you out:

[http://www.tek-tips.com/faqs.cfm?fid=6789](http://www.tek-tips.com/faqs.cfm?fid=6789)

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![jcubed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jcubed](https://www.ruby-forum.com/u/jcubed)\
**Post date:** [May 8, 2010, 6:59pm UTC](https://www.ruby-forum.com/t/tk-images-transparency/188254/3 "2010-05-08T18:59:15Z")

</div>

> This should help you out:
> 
> [How do I use transparency in my Tk window icons? - Perl FAQ - Tek-Tips](http://www.tek-tips.com/faqs.cfm?fid=6789)

Actually looks like I’m a bit wrong about that (that’s for window  
icons)… but this seems to indicate that at least PNG alpha-channel  
transparency works. I couldn’t find much info on GIF transparency.

[http://docstore.mik.ua/orelly/perl3/tk/ch17\_11.htm](http://docstore.mik.ua/orelly/perl3/tk/ch17_11.htm)

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![jcubed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@jcubed](https://www.ruby-forum.com/u/jcubed)\
**Post date:** [May 9, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/tk-images-transparency/188254/4 "2010-05-09T16:51:04Z")

</div>

Jonathan N. wrote:

> > This should help you out:
> > 
> > [How do I use transparency in my Tk window icons? - Perl FAQ - Tek-Tips](http://www.tek-tips.com/faqs.cfm?fid=6789)
> 
> Actually looks like I’m a bit wrong about that (that’s for window  
> icons)… but this seems to indicate that at least PNG alpha-channel  
> transparency works. I couldn’t find much info on GIF transparency.
> 
> [Tile and Transparent Images (Mastering Perl/Tk)](http://docstore.mik.ua/orelly/perl3/tk/ch17_11.htm)
> 
> -Jonathan N.

Thanks, but I don’t think ruby has native support for PNGs and after  
some more research, it doesn’t have support for transparent GIFs  
either… there is an extension called Img, but I’m not sure how to  
integrate that into Ruby…
