It is currently Sat Sep 26, 2026 11:20 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Semi-transparent background for a html div element (solved)
PostPosted: Mon Jan 09, 2012 12:21 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2011
Posts: 395
Location: Indianapolis, IN
GIMP Version: 2.6.11
Operating System: Windows
OS Version: Vista Ultimate 64-bit
GIMP Experience: Basic Level



Greetings!

I'm loosing my mind! Slowly, but it's going!

I want to use this muted white background inside of a html div element as it's background.

I start with a transparent bottom layer, add a top layer filled with white and reduce the opacity to 60%. Yes I have and alpha channel! I then save it as a .gif file. When I go to use it I just get an all white image.

I'm confused! Is there a trick to saving a semi-transparent image??

Attachment:
semi-trans.xcf [879 Bytes]
Downloaded 118 times

_________________
"That which does not kill us makes us stronger." ~ Friedrich Nietzsche


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Semi-transparent background for a html div element
PostPosted: Mon Jan 09, 2012 12:29 am  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
MrBiggz wrote:
... I then save it as a .gif file. When I go to use it I just get an all white image.

I'm confused! Is there a trick to saving a semi-transparent image??

Save your image as a PNG file. The GIF file format does not support partial transparency (colors must be either fully opaque or fully transparent).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Semi-transparent background for a html div element
PostPosted: Mon Jan 09, 2012 12:51 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2011
Posts: 395
Location: Indianapolis, IN
Oh! Didn't know that! After all these years of messing with this stuff .. Cool! Thanks!

_________________
"That which does not kill us makes us stronger." ~ Friedrich Nietzsche


Top
 Post subject: Re: Semi-transparent background for a html div element (solved)
PostPosted: Mon Jan 09, 2012 5:15 am  (#4) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
I would just add that while GIMP can save indexed PNG files (by converting your image to Indexed mode before saving), the transparency of the resulting image will be just the same as if you were to save the file as a GIF. This is a bit unfortunate since the PNG file format allows indexed images to have various levels of transparency, with the tradeoff being that a color is lost for each level of transparency. E.g., you could have 240 opaque colors with 16 different levels of transparency; or 128 colors with 128 levels of transparency -- or (the GIMP default and the only option available with GIFs) 255 colors and 2 levels of transparency (opaque or transparent).

In many cases, indexed PNG images will be much smaller than their RGB counterparts (as much as 90% savings) and the degradation of image quality may be acceptable depending upon your needs. If you want to take advantage of these smaller filesizes then you will need to use a program other than GIMP that does a better job of producing indexed PNG files.

The following image was produced with PNGNQ and is only 74Kb.

Attachment:
test-nq8-defaults.png
test-nq8-defaults.png [ 73.71 KiB | Viewed 2356 times ]


Here is the original RGB PNG, which has a file size of 550Kb.

Attachment:
test-rgb.png
test-rgb.png [ 556.31 KiB | Viewed 2356 times ]


And here is the image saved as a GIF, with a file size 80Kb (larger than the indexed PNG). As previously discussed, the partial transparency is lost. The image is basically of lower quality than the indexed PNG, but this is attributable to the improved conversion algorithms of the PNGNQ program. I used GIMP to create the GIF file and there are other dedicated GIF convertors that do a better job and should be able to match the quality of the indexed PNG (disregarding the transparency issue).

Attachment:
test-rgb.gif
test-rgb.gif [ 80.13 KiB | Viewed 2356 times ]


Unfortunately, GIMP will incorrectly load the indexed PNG (the first of the above images) as though it were an indexed GIF, corrupting the transparency information and producing an image similar to the GIF image above. Nonetheless, your webpage should display the image properly.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Semi-transparent background for a html div element (solved)
PostPosted: Mon Jan 09, 2012 9:32 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2011
Posts: 395
Location: Indianapolis, IN
Thanks Saul!

Although I had to go and find the hack for IE an png's. After all these years IE still doesn't like to handle alpha in PNG's. One of the many in a laundry list of reasons I cannot stand IE!!

_________________
"That which does not kill us makes us stronger." ~ Friedrich Nietzsche


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group