Jump to content

Php GD, more than 1 transparent color?


Michdd

Recommended Posts

That is because transparency is created by defining only one color value as transparent.  Partial transparency is available in PNG, using Alpha channels, however an image with an alpha channel is a completely different beast. 

 

Alpha channels involve the combination of a per pixel Alpha blending value.  So the first thing you need to know is that alpha channels in the png spec only work with png images that use 8 or 16 bit color.    Rather than specify a color that should be rendered transparent, an alpha channel acts as a mask value on a per pixel basis, indicating what opacity the pixel should have.  This is simplifying the question a bit, because png's using an index table, can also specify an alpha value for a particular color in the color table index, which is probably the closest thing to what you originally inquired about.

 

There's an example of merging images to create a watermark effect in the php manual that touches upon some of this material:

 

http://us.php.net/manual/en/image.examples.merged-watermark.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.