Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





PHP (GD) Created Transparent PNG: AlphaImageLoader Makes Black Parts Transparent Instead Of Transparent Color Set With PHP


I have a problem with PHP (GD) created transparent PNG and Microsofts
AlphaImageLoader.

You will immediately see what the problem is if you view
http://www.useful-scripts.biz/test/.../transpng_2.php with IE 7
or Firefox and then with IE 6. It seems that the AlphaImageLoader
works correctly on a PNG image that has been created with an image
processor and then uploaded, but not with a PNG image created with
PHP. It seems to ignore the transparent color set with PHP and instead
to render the black color transparent.

The image in question was created using this code:

<?php
$source = imagecreatefrompng("parrot_orig.png");
$transp = imagecolorallocate($source,255,0,0);
imagecolortransparent($source,$transp);
imagefilledrectangle($source,15,15,70,70,$transp);
imagepng($source,"parrot_php.png");
?>

The HTML used on the page is this:




View Complete Forum Thread with Replies

Related Forum Messages:
Remove A Black Background From An Image To Make It Transparent Using GD
is it possible to remove a black background from an image to make it transparent using GD. for example. can i pass the radius of the moon to GD (as it is on the image) and have it slice the moon out so to speak leaving it on a transparent background.

View Replies !
Define The Transparent Color
I've made a script that takes images (in gif,jpg & png) and makes their thumbs in jpg format. Now, the problem is if I have a transparent gif when saved to jpg the part of the original picture that is transparent turns black in the new thumb. My question is: how can I define that the transparent part gets the color i want it to get (white is what i need) ?

Actually, I now what in theory should be done. I should change the r,g,b values of the color that has aplha=127 (and that's not a problem with imagecolorset()), but also I should change the alpha of that color to 0. how can that be done ? My quess is that that is the right way to do it.

View Replies !
[GD]: Open Existing Image(url) & Set A Transparent Color
lets say i output an image like this:

$img = array('somedomain.com/foo.jpg');

<img src="$img[0]" alt="" />

but it has a white background and i want to strip the white background to be transparent

how do i do that and output it inline again?

View Replies !
Transparent GIF
I am trying to resize transparent GIF images, so I was reading, and they say to use fopen, fread, and read the first 13 bytes... OK, so I read in a transparent gif, and the first 13 bytes... and echo it out to the screen, and I get this: GIF89a›&#65533;s&#65533;÷&#65533;&#65533;What am I supposed to do with that? they then say "allocate that color as transparent, and use imagecopy(); to set the transparency back."

View Replies !
Transparent .png
This isn't totally related to php, but I am using a php generated page that is using transparent .png's.

Anyway, when I view the page in Internet Explorer, the transparency within the png is replaced with grey?? But when I view it in Firefox it works fine?

View Replies !
Transparent Image
Hi!

Here's a piece of code:

[begin]

<?php

Header('Content-type: image/png');

$sz = "";

$FileValue = 1000;

$i = strlen($FileValue);

for ( $j = 0; $j < 7-$i; $j++ )
{
$sz = $sz . "0";
}

$Img = imagecreate(56,13);

$Gold = imagecolorallocate($Img,148,128,100);

$Gray = imagecolorallocate($Img,32,32,32);

ImageFilledRectangle($Img,0,0,55,12,$Gray);

imagestring($Img,4,0,0,$sz.$FileValue,$Gold);

imagepng($Img);

ImageDestroy($Img);
?>

[end]

OK. Calling this script I have a png picture back.

Now I add imagecolortransparent($Img,$Gray); just before imagepng() and OK
again, I have a transparent picture back. But now, if I add:

$r = imagerotate($Img,90,0);

imagepng($r);

just after the imagecolortransparent() instruction seen above, I get a
rotated picture, but not transparent. How to solve that? I've used a plenty
of tricks, no one works.

View Replies !
Transparent GD Watermark.
Any one know what would be the best way to accomplish a transparent watermark on upload with GD that will work for Jpegs, Gifs and Pngs,  using only GD in php 4?

View Replies !
Resize Transparent PNG
I have a basic script to resize a transparent png image. Code:

$dimg = imagecreatetruecolor($newwidth, $newheight);
imagecolortransparent($dimg, imagecolorallocate($dimg,0,0,0));
imagealphablending($dimg, false);
imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);


Problem is that my nice drop shadows are lost in resize. Does anyone know how I can keep them ?

View Replies !
Transparent Background
i'll try to explain myself the best i can, here is the problem:

i have a html page and inside this i want to put an iframe that contains a php page. That's ok, i can do it and it works, but the problem is that i can't make that php document to have transparent background.

it turns white. Is it because of the iframe? the php document has transparent background, but when i see it inside the iframe it doesn't work.

View Replies !
Two Transparent Colours
I have an image that I am opening and then merging onto another image, and it has two colours which I wish to make transparent, but it is not working, can you please give me an example of how to do this thanks. When I say that it is not working, I mean that when I allocate the second one, the first one is no longer transparent.

View Replies !
Transparent Overlay Watermark - On The Fly?
Is it possible to overlay a transparent watermark on an image -
dynamically?

I'd like the result to look like this example:
<http://www.cycletourist.com/temp/photo.php>

That is a bit of overkill, but you can see what I mean. The watermark
image (a png image) is included separately below the photo.

I tried using a class from phpclasses.org
<http://www.phpclasses.org/browse/package/1580.html...
but the result looks horrible. The transparency does not work.

I found one other method through Google,
<http://www.sitepoint.com/article/watermark-images-php>
but it did not work, either.

Can this kind of transparent overlay be done on the fly with GD lib?

View Replies !
Dynamically Transparent Gif's
Basically what i would like to do is dynamically set the transparency of a selection of images (GIF'S) depending on variables set in a My SQL Database. What i need to do is tint some jpg,s by setting the transparency of a solid blue gif which is set over the top of it in a table.

View Replies !
GD: Testing A Pixle To See If It's Transparent?
How would I determine if a pixel is 100% transparent on a given image?

View Replies !
Imagegettftext Transparent Holes
I created an image, made it transparent, drew a rounded rectangle on it and then wrote on it with imagegettftext - where the text is there are transparent holes.

$image = imageCreateTrueColor($width,$height);
imageSaveAlpha($image, true);
ImageAlphaBlending($image, false);

$transparentColor = imagecolorallocatealpha($image, 255-$r, 255-$g, 255-$b, 127);
imagefill($image, 0, 0, $transparentColor);

$background = imagecolorallocate($image, $br, $bg, $bb); .......

View Replies !
Find Out If An Image Is A Transparent Gif
Does anybody know if there's an easy way to find out if a given image is a transparent gif? (GIF89a)

View Replies !
Transparent Watermarks On Images
I'm using the code below to make a watermark and it's kinda working, but I want it semi-transparent as the PNG file is itself.

Is there an easy way of overlaying transparent images in the GD library, so that the original image is merged in such as way that it can be seen through the watermark? Code:

View Replies !
Make Thumbnail Transparent
I have a script that will upload an image, then create a thumbnail of that image. When I upload an image with a transparent background the normal sized image comes out with a transparent background, but the thumbnail image comes out with a black background. Code:

View Replies !
Transparent Text On Image?
Is it possible to place transparent text on an image? I want to display an image of some text in a fancy typeface, but superimpose text in a plain style, so that it can be copied and pasted; a bit like what you see in some PDF files, where the page image is visiable, the overlying text is not.

View Replies !
Transparent Filled Polygon
I'm working on a map program where each building is clickable and when it's clicked the page is refreshed to show a map with the building highlighted (in red). I was wondering if it would be possible to highlight the buildings using some sort of combination of the imagepolygonfill function and a transparency function (i'd like the buildings to still be visible under the highlight), rather than having to create many different files with the different buildings highlighted.

View Replies !
Make A Colour Transparent
I would like to do is grab an image, determine what colour is at a certain pixel (maybe 10, 10) and then set that colour to transparent for the whole image. Basically it is so that I can dynamically place an image on various backgrounds for previewing. I am not worried about perfection (anit-aliasing, matte, etc).

View Replies !
Add Transparent Copyright Text To Image
I need a way to add a transparent copyright message (e.g. copyright 2002 together with my company logo) to my photos on the fly. My photos come in many different formats, such as PNG, GIF and JPEG.

View Replies !
.htaccess Transparent SESHID And Sessions
just putting the finishing touches on a shopping site and have run into errors in the process when users are blocking cookies. i am using:

<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>

in my .htacess file to supress the PHPSESSID=22y3213etc. but it means that if a cookie isn't set the site fails to work properly.

if i remove that from my .htaccess the site works fine because the PHPSESSID is passed around evey page, but it knackers things for SEO purposes. Code:

View Replies !
GIF Resize Resample Transparent Fill
I am currently trying to create what I would think is simple. I want to create a image.php file and have it resize a 80 x 80 image to 29 x 29 with out losing the quality. When I try to have the gif image imagefill with the color white (255,255,255) it holds up and ends with a timeout. The gif images also have the black pixels if i don't try filling.

Does anyone know a simple script to just resize a gif/jpg file? All documentation has been pretty bad so this is first time posting.

View Replies !
Create Or Resize Transparent .png - Drop Shadow - GD IM
I've searched and d/l'd but cant seem to find a way of creating
a semi-transparent drop shadow for an image.

Let me say, be fore I go on, I *do not* want one of those scripts that
resizes your image a bit to the left and bottom, and then grafts a
shadow onto it. I want to use a full shadow (it would be about as big
as the image) and shift it a bit with CSS. So, I will have the image
sitting in a DIV which will have the shadow as a bg. This works fine
doing it manually.

So, I would like to find one of two alternatives:

1. (best) Create the shadow from given parameters(size, darkness,
spread, etc.) I will write the .png to a folder, I dont really need to
create it dynamically each time, but want the ability for the future
(galleries) and for when I'm in development and images are changing,
moving around, etc.

2. (will work) Take a pre-existing shadow and resize it as needed, but
has to keep the transparency.

View Replies !
How Do I Echo A Binary Array (transparent Pixel)
What am I doing wrong here? I want to display a transparent pixel...

<?
$transparent1x1 = array (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0,
0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0,
1, 0, 0, 2, 2, 68, 1, 0, 59);
header("Content-type: " . image_type_to_mime_type (IMAGETYPE_GIF));
echo $transparent1x1;
?>

View Replies !
Security - Detect If A Client Is Connecting Through A Proxy(inluding Transparent) Or Not.
I want to detect if a client is connecting through a proxy(inluding transparent) or not.  What measures can I take to authenticat the source of the request before I even ask for login details. $_SERVER['REMOTE_ADDRESS'] is the only thing I can think of using but surely it is not sufficient to trust its value.

View Replies !
Put Transparent Layer That Disable Page Element At The Time Of Processing Ajax
I have made web page in php with the help of ajax and javascript. I want to do whenever page processing for ajax for that time I want to put some transperent layer that will disable the back pages element.. I have seen one site but I dont remember.

View Replies !
Creating Image From Uploaded Image And Transparent PNG
Say the client wants to be able to change the image, but not the text treatment, and doesn't have the Photoshop knowledge to actually replace it and re-save it themself.

Is there anyway to use a PNG with the rounded edges, text treatment, and transparent center, have the client upload a standard rectangular-shaped image, and use PHP to layer the uploaded image underneath the transparent one, creating a new image file?

View Replies !
Retaining Black Color
What I'm doing is changing the color of one image and then overlaying it on top of another with an opacity of around 35%. The bottom image contains pure black text. What I want to know is if there is a way to merge the two images while retaining the color of the black text underneath. A lot like using a multiply layer in Photoshop. I'm not even sure if this is possible, or if I'd be simply better off just having a separate layer/image just for my black text.

View Replies !
Recode From Color To Black And White
try to recode my php code below from generating just a black and white image. the code below takes time to process cause its trying to generate as much colors as it could receive from its source, but the thing is, the source is just passing black and white colors.. Code:

View Replies !
Imagerotate(), Producing A Black Background Color
I am having this Image, the background of the image is transparent

But on rotation using imagerotate(), it is producing a black background color.

This background color is coming on using any function on the original image
ie, like imagecopy() etc . I have used imagecolortransparent() to suppress the
color, but still the problem is coming.

View Replies !
[fopen()] Unzip Uploaded File To Created Newly Created Directory
Right i have already spent the best part of 8 hours trying to get this working.

What i am trying to do:

Upload zip file to directory. Check if upload is successfull and then unzip to directory created by name of zip file.

I can upload the zip file and create the diectory but the damn files wont unzip to the newly created directory ....

View Replies !
$parts = $struct->parts;
Turning on error_reporting(E_ALL); was quite an eye opener as to
how much "fixing" PHP will do for the sloppy coder.

I fixed all of the errors except:
Notice: Undefined property: parts in
/ContactManagement/contact_mainpage.php on line 120

where the line in question is:
$parts = $struct->parts;

where $struct = = imap_fetchstructure($in, $mid);

$struct is an object, parts is an array of objects

what would the correct syntax of the statement be ?

View Replies !
Color Background Cell Color Per Row
I am trying to create a display page for my database records, where each display-row has a different color than the previous one. I think I can do that if I where able to get the rownumber of the recordset. Than for each 'even' number I asign a color, and for each 'uneven' number a different one. Code:

View Replies !
Application That Makes Thumbnails
I'm trying to make an application that makes thumbnails but I can't make it work and i doesn't give me any error in return not even in the log file. Code:

View Replies !
What Makes Gethostbyaddr Fail?
I'm starting to get familiar with the gethostbyaddr function, and notice that sometimes it returns the exact ip address that I'm trying to get the host by.

I read on PHP's website that gethostbyaddr "returns the host name of the Internet host specified by ip_address or a string containing the unmodified ip_address on failure."

However, I'm curious. What makes gethostbyaddr fail, and is there anything I can do to help it not fail, or is there a related function that might work if it does?

View Replies !
Create A Loop Which Makes A Form
Is it possible for me to create a loop which makes a form for me over and over again until it has done 30? I need this to be repeated over and over, yet everytime it increments the name. So, in this example, it would be thing then thing1 then thing2etc allthe way until thing29. Code:

View Replies !
Htmlspecialchars Makes Stuff Safe?
Do you think using the htmlspecialchars function makes user input safe for the mysql database? If not, what other exploits are there? Do I really need to add more to make my user input secure?

View Replies !
Code Makes A Blank Page?
I upgrade from PHP4 to PHP5.4.2 and now this code doesn't work.  I moved the header command up to the top (you can see where I commented it out lower in the code) and now all that show is the header.  If I have the header in the original position the page is blank. Code:

View Replies !
UTF-8 Makes Php Add Wierd Symbols After Require().
As some of you may know (for those of you that have been following my threads...) I recently changed my php file formats to UTF-8.

THE PROBLEM It seems that doing that made PHP create, by itself if I may add - cause I didn't bloody ask it to! - some weird characters at the top of the html document page.

Yes that's right, at the top; just enough to mess my otherwise perfect XHTML strict document - am I the only one that is starting to think that these errors and strange behaviours from programs are intentionally created to maximize one's frustration?


View Replies !
Loading Page Makes My Server Reboot
I have a simple page with a bit of php code on it. The code is below: PHP Code:

View Replies !
Changing Filename Makes Getimagesize Work...?
I'm having troubles uploading an image and getting data from
getimagesize().

When I upload a file with the name "20050914_loRes_XLH1.jpg", and do a
getimagesize on it, it returns no info (null and empty). However, if I
change the filename to something like "camera.jpg" and upload it,
getimagesize() works perfectly, and I can print_r the array of data.

PHP is uploading the files to my /var/temp directory just fine. Also,
I have all errors turned on, and nothing looks out of place.

View Replies !
One Result Set Makes Two Lists With Same Keys And Values
I have a page with two drop-downs, each listing the same employee names
and their id's as the values. So they look like:
<select name="selection_1">
<option value="12">Curly</option>
<option value="8">Larry</option>
<option value="36">Moe</option>
</select>

....then further down the page:

<select name="selection_2">
<option value="12">Curly</option>
<option value="8">Larry</option>
<option value="36">Moe</option>
</select>

Currently I am doing this, which works but seems sloppy:

<select name="selection_1">
<?
while($employees=mysql_fetch_assoc($qry_rslt)) {
/* ADD NAMES TO DROPDOWN WITH emp_id's AS THEIR VALUES */
?><option
value="<?=$employees['emp_id']?>"><?=$employees['name']?></option><?

/* CREATE ANOTHER ARRAY WITH THE emp_id AS THE KEY */
$emp_list_2[$employees['emp_id']]=$employees['name'];
}
?>
</select>

Then on the second drop-down:

<select name="selection_2">
<?
foreach($emp_list_2 as $key => $emps) {
?>
<option value="<?=$key?>"><?=$emps?></option>
<?
}
?>
</select>

View Replies !
What Makes A Site Go To The Page Where A Form Is Being Submitted?
When a form is submitted what is it that makes the user visit the page the form is submitted to?

I have a form that doesn't do this when I want it to, because of this currently the form only works when its on the page its submitted to. Code:

View Replies !
Script Which Gets The Users Login Name And Makes It An Image
im creating a script which gets the users login name and makes it an image with a font which works..

$text = $_SESSION['username'];
$width = 23 * strlen($text);
$im = @imagecreate ($width,30)or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 150, 174, 101);
$text_color = imagecolorallocate($im, 225,225, 225);
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 20, 0, 0, 20, $black, "arial.ttf", $text);
imagepng($im);
imagedestroy($im);

the only problem is that the length of the text is really off sometimes...
is there anyway i can sort this out?

View Replies !
MySQL Makes A Server Load And Crashes
As you see server load is too much and its getting more then mysql service stops and everything is normal. This happens for 2 days, hosting company made a Linux kernel update maybe that can be the reason.

My VPS load was always too high and there is only 1 site got 10.000 unique visitors. I did so many optimizations on the mysql queries and also php. I cant afford a dedicated server at this time and I dont think it's not so much traffic.

View Replies !
How The Script Makes The Inputs, Is Recieved With White Space
The function works fine really in my setup. The email is sent, and it's formatted as i'd like with one draw back. Every email I send with the function, regardless of how the script makes the inputs, is recieved with white space at the top of the email. Has anyone encountered this before?

View Replies !
A Method To Suggest Other Names When User Makes Typos
Working with Apache+PHP+MySQL, I'm developing a website to allow users to find within a product catalog. Product info is stored within a MySQL table (ID, name, price).

These users usually make typos and mistakes when typing the product name, and I want to suggest them other names, similars to the typed one. For instance:
mp3 playr --> mp3 player

Does anybody know any algorithm or method to perform it?

View Replies !
Black Box
I have php installed, It just brings up the black box. How do I make it work?

View Replies !
Storing Images In Database - Makes Page Load Much Slower?
I have just taken over a site which was developed in php / mySQL. It is a large shopping cart system. I was shocked to learn that their mySQL database was over 1GB in size. I have seen forum DB's get very large but never that large for a shopping cart site so I investigated further.

It turns out they have stored all of the product images and I believe even many of the basic site images in the database itself as a longblob type. There is one table that is 860MB in size. Code:

View Replies !
My Thumbnails Are Black
The code below is mean to create thumbs for all images in a folder however they just come out black. Is there an arror or is it a gd function that isnt supported with gd 2.0.28 Code:

View Replies !
Black Border
I'm trying to draw a black border around all my pictures. I get a border as the result but. The borders are all kinds of colors, different grays, white and black. It seems like random. I want black and only black. PHP Code:

// Create border around image
$black = imagecolorallocate($image,0,0,0);
imageline($newimg, 0, 0, 0, $new_height, $black);
imageline($newimg, 0, 0, $new_width, 0, $black);
imageline($newimg, $new_width-1, 0, $new_width-1, $new_height-1, $black);
imageline($newimg, 0, $new_height-1, $new_width-1, $new_height-1, $black);

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved