Jump to content

GD Transparent Cutout


jeff205

Recommended Posts

I am using the following code to give my image round corners, but i am using an image that just cuts the corner with a white shape. Is it possible to make it cut the corner with a transparent color?

 

function roundcorners($image, $topleft, $topright = null, $bottomright = null, $bottomleft = null) {
		if($topright == null) $topright = $topleft;
		if($bottomright == null) $bottomright = $topleft;
		if($bottomleft == null) $bottomleft = $topleft;
		if($topleft >= 2) {
			$tl = imagecreatefrompng("corner.png");
			imagecopyresampled($image, $tl, 0, 0, 0, 0, $topleft, $topleft, 485, 485);
		}
		if($topright >= 2) {
			$tr = imagerotate(imagecreatefrompng("corner.png"), 270, 0);
			imagecopyresampled($image, $tr, imagesx($image)-$topright, 0, 0, 0, $topright, $topright, 485, 485);
		}
		if($bottomright >= 2) {
			$br = imagerotate(imagecreatefrompng("corner.png"), 180, 0);
			imagecopyresampled($image, $br, imagesx($image)-$bottomright, imagesy($image)-$bottomright, 0, 0, $bottomright, $bottomright, 485, 485);
		}
		if($bottomleft >= 2) {
			$bl = imagerotate(imagecreatefrompng("corner.png"), 90, 0);
			imagecopyresampled($image, $bl, 0, imagesy($image)-$bottomleft, 0, 0, $bottomleft, $bottomleft, 485, 485);
		}
	}

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.