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

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.