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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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