PHP - Convert Monochrome
Submitted by admin on Wed, 08/01/2007 - 16:17.
::
This function will convert JPEG image to monochrome, reduce the filesize 90%, and increase the readability. All good things. Please implement this.
Note: This requires that you have PHP GD installed for Image manipulation.
function convertJPEGtoMonochromeGIF( $infile, $outfile ) {
list($width, $height) = getimagesize($infile);
$source = imagecreatefromjpeg($infile);
$bwimage= imagecreate($width, $height);
$paletteBlack = imagecolorallocate( $bwimage, 0, 0, 0 );
$paletteWhite = imagecolorallocate( $bwimage, 255, 255, 255 );
for ($y=0;$y<$height;$y++)
for ($x=0;$x<$width;$x++)
{
$rgb = imagecolorat($source,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$gs = (($r*0.299)+($g*0.587)+($b*0.114));
if ( $gs > 150 )
imagesetpixel($bwimage,$x,$y,$paletteWhite);
else
imagesetpixel($bwimage,$x,$y,$paletteBlack);
}
imagegif( $bwimage, $outfile );
}
How can i find the URL's Captcha Image?
I don't understand how it works.
What do i have to do to use correcly the API code?