Jump to content

PHP gd - image alpha(ing)


helppy

Recommended Posts

I am faced with problems using php gd as i am doing some image manuplication.

I am actually trying to display an image (e.g 800*600) as the main display then having a photo (e.g 100*70) on top on it, with a starting co-ordinate points of (0,0).

I am able to display the photo on top of it but am unable to alpha the photo so that the display area behind the photo is visible too.

does anyone knows how to solve my problem?

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/27433-php-gd-image-alphaing/
Share on other sites

<?php

$im_a = @imagecreatefrompng("images/Water lilies.png");

//$im_b = @imagecreatefrompng("images/SunsetEDIT.png");

$im_b_x = 10;
$im_b_y = 10;

$im_b = imagecolorallocatealpha($im_a, 0, 0, 0, 50);
imagefilledrectangle($im_a, 0, 0, 100, 100 , $im_b);

//$im_c = imagecolorallocatealpha($im_a, 255, 0, 0, 50);
//imagefilledrectangle($im_a, 0, 0, 200, 200 , $im_c);

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

?>

--------------------------------------------------------------------------------------------

<?php

$adImage = ImageCreateFromJPEG('images/Water lilies.jpg');
ImageAlphaBlending($adImage, true);

$photoImage = ImageCreateFromJPEG('images/top.jpg');
//$photoImage = imagecolorallocatealpha($adImage, 0, 255, 0, 50);
$logoW = ImageSX($photoImage);
$logoH = ImageSY($photoImage);

ImageCopy($adImage, $photoImage, 0, 0, 0, 0, $logoW, $logoH);

//output to browser
ImageJPEG($adImage);

ImageDestroy($adImage);
ImageDestroy($photoImage);

?>

--------------------------------------------------------------------------------------------

Both have different output:
First one, it has alpha but its a drawn rectangle.
Second one, has photo overlap but not alpha.

The output i hope to get is the combining of both - photo that is being alpha.

thanks!!!
Link to comment
https://forums.phpfreaks.com/topic/27433-php-gd-image-alphaing/#findComment-125635
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.