<?php
function
negate($image){
if(function_exists('imagefilter')){
return imagefilter($image, IMG_FILTER_NEGATE);}
for($x = 0; $x < imagesx($image); ++$x){
for($y = 0; $y < imagesy($image); ++$y){
$index = imagecolorat($image, $x, $y); $rgb = imagecolorsforindex($index); $color = imagecolorallocate($image, 255 - $rgb['red'], 255 - $rgb['green'], 255 - $rgb['blue']);imagesetpixel(
$im, $x, $y, $color);}
}
return(true);}
$image
= imagecreatefromjpeg('image1.jpg');if
($image && negate($image)){
echo 'Image successfully converted to negative colors.';imagejpeg(
$image, 'image1.jpg', 100);imagedestroy(
$image);}
else
{
echo 'Negative color conversion failed.';}
?>
After running the program you will get the following output
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.