GD - JPEG to PNG with transparency and color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Following files:

bg.png – Clear Transparent Image

14416fed5d4f78.jpg – Normal Jpeg Image

 

 

The Code:

 

header('content-type: image/png'); 

 

$watermark = imagecreatefromjpeg('14416fed5d4f78.jpg');

 

$watermark_width = imagesx($watermark); 

$watermark_height = imagesy($watermark); 

 

$image = imagecreatetruecolor($watermark_width, $watermark_height); 

$image = imagecreatefrompng('bg.png'); 

 

$size = getimagesize('bg.png'); 

 

$dest_x = $size[0] - $watermark_width - 5; 

$dest_y = $size[1] - $watermark_height - 5; 

 

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);

 

imagepng($image);

 

imagedestroy($image); 

imagedestroy($watermark);

 

 

The Problem:

 

The code above works fine in sense of syntax! bg.png acts as a transparent border for 14416fed5d4f78.jpg to keep the size of bg.png and not the size of 14416fed5d4f78.jpg so it doesn’t blow up 14416fed5d4f78.jpg. However, the image comes out black/white and has lost its color!

I looked all over Google and I’ve found nothing so far that’s functional to give the new created png file the correct colors as the original 14416fed5d4f78.jpg. I figure that I’m missing some small elements to the process of creating the png…

Anyone have any ideas, pointers, advice, or correct solution to make this possible?

 

Sincerely,

 

Travis L. Font

Interactive Developer

 

BSN

5901 Broken Sound Parkway NW
6th Floor

Boca Raton, FL 33487

Main Ph.: 561-994-8335 Ext.737

Fax: 561-998-4635

Toll Free:  1-800-939-4071 Ext.737

www.BSNonline.net  / www.EndoRush.com / www.TLFapparel.com

 

The 27th Fastest Growing Private Company In America*

The 2nd Fastest Growing Private Company In The Miami-Fort Lauderdale Metro Region*

The 4th Fastest Growing Private Company In The Health Industry*

[*Above Rankings Were Determined By Inc. 500/5,000]

 

This e-mail, and any attachment, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, copying, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The contents of this message may contain personal views which are not the views of BSN.


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux