?
Solved

Transparency Gd Library (Easy)

Posted on 2006-04-11
8
Medium Priority
?
237 Views
Last Modified: 2008-03-10
I have a red image with blue text and am trying to make the red  in the image transparent... it doesnt work.. Any ideas??
Thanks

  $image       = 'ImageManipulation/TemoraryImages/blue.gif';
    $image       = imagecreatefromgif($image);
    //Make transparent all red in the image
    $MakeTrans   = imageColorAllocate($image, 255,0,0);
    imagecolortransparent($image,$MakeTrans);
    imagegif($image);

0
Comment
Question by:boss234
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:BogoJoker
ID: 16428726
I don't know much about images, I know some people here do though, so i'll just do my basic error checking =)
Are you sure the color that your trying to make transparent is exactly (255,0,0)?
Joe P
0
 

Author Comment

by:boss234
ID: 16428754
Yes, i just made it to test the code.
M
0
 
LVL 9

Expert Comment

by:pallosp
ID: 16429833
The problem is that you create a new red palette entry and make that transparent.
The original red pixels still remain red. You should find the palette index used for red pixels and make it transparent.
I'm now looking for the php function to read the palette.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:pallosp
ID: 16429886
I've found it: the palette index of the red color can be retieved by the imagecolorexact function.

http://hu2.php.net/manual/en/function.imagecolorexact.php
0
 

Author Comment

by:boss234
ID: 16430546
Thanks pallosp - - i get a pallet index of ZERO (0) is this right?

Regards
0
 
LVL 9

Accepted Solution

by:
pallosp earned 2000 total points
ID: 16430940
If making the 0th element transparent solves your problem, definitely it is right.
-1 means that the given color doesn't exist, so 0 can be a right index.
You may check it by a photo editor that is able to display the palette of an image (such as Paint Shop Pro).
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question