PDA

View Full Version : upload gif o png image



esferaweb
December 11th, 2007, 07:31 AM
Hey,

how can i change, with php, background color of uploaded image in gif or png format with transparent background? is it possible?

tks.

simplistik
December 11th, 2007, 09:45 AM
you can use the GD library to layer a color below it, then recompile the image. we use a method sorta like this we allow a user to upload their image and then pick a .png frame (or force it on them) and then it merges the two images.

i can't show you the source, but it can be done.

esferaweb
December 11th, 2007, 08:20 PM
i tried this:



header("Content-type: image/png");

$de = imagecreatefrompng('produto.png');

$imagem = imagecreatetruecolor(400, 400);

imagecopyresampled($imagem, $de, 30, 30, 0, 0, 100, 100, imagesx($de), imagesy($de));

imagecolorallocate($imagem, 233, 14, 91);

imagepng($imagem);

imagedestroy($imagem);


but not working, the image is created with black bg
if anyone can help thanks