Jump to content

Image GD making a setting opacity to an image


x1nick

Recommended Posts

Basically I want to open up a png file with a transparent background which is 48x48 pixels

And set the opacity of this to about 50% of the original.

 

I have the following to do what I want but just returns an empty image

On imagecolorallocatealpha i have tried setting the alpha value at different values between 0 and 127 with no success as 127 returns a black block

 

imagecopy($menu,$image,
	#Positioning
	0,0,
	0,0,
	#Image size
	48,48
);
#Create transparent block
$new_img = imagecreatetruecolor(48, 48);	
imagealphablending($new_img, true);
$transparent = imagecolorallocatealpha($new_img, 255, 255, 255, 0);
imagefilledrectangle($new_img, 0, 0, 48, 48, $transparent);
#Put block over original image
imagecopy($menu,$new_img,
	#Positioning
	0,0,
	0,0,
	#Image size
	48,48
);

 

The image below shows on top the original and on bottom what I am roughly trying to create

 

plus2states.png

 

Where am i going wrong?

 

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.