Image effetcs





/*$image = imagecreatefrompng("galapagos.jpg");
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagefilter($image, IMG_FILTER_NEGATE);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);*/

$base_img_dir = "img/";

$img_conv_dir = "./bin/";

echo "filename :".$filename= "galapagos.jpg";
// retrieve image info
$imginfo = getimagesize($filename);

echo "imageinfo:".$imginfo[2];

// handle image according to type
switch ($imginfo[2]) {
case 1: // gif
// convert gif to png using shell command
$command = $img_conv_dir."gif2png $filename";
exec($command);

// remove original gif file and rename converted png
unlink($filename);
rename("$filename.png", $filename);

// check png image by loading and saving the file
// to prevent wrong uploaded files and errors
$img = imagecreatefrompng($filename);
imagepng($img, $filename);
imagedestroy($img);

// set image type to png
$img_type = "PNG";
break;
case 2: // jpeg
// check jpeg image by loading and saving the file
// to prevent wrong uploaded files and errors
$img = imagecreatefromjpeg($filename);
imagejpeg($img, $filename);
imagedestroy($img);

// set image type to jpeg
$img_type = "JPG";
break;

case 3: // png
// check png image by loading and saving the file
// to prevent wrong uploaded files and errors
$img = imagecreatefrompng($filename);
imagepng($img, $filename);
imagedestroy($img);

// set image type to png
$img_type = "PNG";
break;
case 4: // bmp
// rename file to bmp
rename($filename, "$filename.bmp");

// convert bmp to png using shell command
$command = $img_conv_dir."bmptoppm $filename.bmp | ".
$img_conv_dir."pnmtopng > $filename";
exec($command);

// remove original bmp
unlink("$filename.bmp");

// check png image by loading and saving the file
// to prevent wrong uploaded files and errors
$img = imagecreatefrompng($filename);
imagepng($img, $filename);
imagedestroy($img);

// set image type to png
$img_type = "PNG";
break;

default:
break;
}

POPULAR POSTS ::

Add multiple upload box

String Separation

The top Web development PHP frameworks

Only number restrictions

HTML Document structure and it's Syntax format

Add and Separate more records by comma operator

Addslashes