PHP image transparency tolerance

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

PHP image transparency tolerance

Post by Pineriver »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've got this to join 2 images together and replace the color blue from TrueColor.jpg with BackGround.jpg.
This works but there are a few blue sploches because not all blue is truely blue. So what I am looking for is a way to bring the blue tolerance up to cover the image. Both images must be a jpeg image and not png or gif.

Code: Select all

$image = ImageCreateFromJPEG("BackGround.jpg");
$icon = ImageCreateFromJPEG("TrueColor.jpg");


$trans = imageColorallocate($image, 0,0,255);
ImageColorTransparent($icon,$trans);
$width = ImageSX($icon);
$height = ImageSY($icon);


ImageCopyResized($image,$icon,0,0,0,0,$width,$height,$width,$height);
thanks


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Moved to: PHPGD.com
Post Reply