Jump to content

GD - Getting Similar Colours


JonnyT

Recommended Posts

Hi. I currently have a script that removes the colour 'white' from an image. However, at the moment it only removes pure white. I was wondering if you guys could help me with allowing the script to also delete colours very similar to 255,255,255.

 

Here is my script so far:

<?php

// Recieving the variables.
$sims3user = $_POST['sims3user'];
print $sims3user;


// MAKE TRANSPARENT
// Load image
$img = imagecreatefromjpeg("http://www.thesims3.com/fetchAvatar/".$sims3user."");

// Make matte canvas
$matte = imagecreatetruecolor(225,225);
$trans_color = imagecolorallocatealpha($matte,255,255,255,0);
imagefill($matte, 0,0,$trans_color);

// Put the old image on the matte
imagecopy($matte,$img,0,0,0,0,225,225);

// Turn the matte color into full alpha (blended pixels will not be affected)
imagecolortransparent($matte,$trans_color);

// Display image
header('Content-Type: image/png');  
imagepng($matte, "/home/missings/public_html/ms/signaturegenerator/custom_sims/".$sims3user.".png");

?>

Link to comment
https://forums.phpfreaks.com/topic/164538-gd-getting-similar-colours/
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.