Jump to content

[SOLVED] Image Functions


loganbest

Recommended Posts

yes do i know, but this is for helping with current script problems not a site for getting scription written for you..

 

But

 

Heres a starting block.. this will convert color to grayscale..its not great needs a few improvments (as the quality drops if used over and over) but it works.. you should be able to alter this to suite your needs

 

<?php
function convert($filename)
{
$filename = imagecreatefromjpeg($filename);
list($width, $height) = getimagesize($filename);

$bwimage= imagecreate($width, $height);

for ($c=0;$c<256;$c++)
{
	$palette[$c] = imagecolorallocate($bwimage,$c,$c,$c);
}

//Reads the origonal colors pixel by pixel
for ($y=0;$y<$height;$y++)
{
	for ($x=0;$x<$width;$x++)
	{
		$rgb = imagecolorat($source,$x,$y);
		$r = ($rgb >> 16) & 0xFF;
		$g = ($rgb >>  & 0xFF;
		$b = $rgb & 0xFF;

		//This is where we actually use yiq to modify our rbg values, 
		//and then convert them to grayscale palette

		$gs = $this->yiq($r,$g,$b);
		imagesetpixel($bwimage,$x,$y,$palette[$gs]);
	}
}
// Outputs a jpg image, but you can change this to png or gif if that is what you are working with
imagejpeg($bwimage, $filename);
imagedestroy($bwimage);
}
?>

 

hope this helps

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.