Posts Tagged ‘syntax highlighting’
- bagheadinc
- | January 5th, 2009 | 12:06 am
<?php
$allowed_mimes=array("image/jpeg","image/gif","image/png");
$dirPath = "./";
$imglist = array();
if ($handle = opendir($dirPath)) {
while (false !== ($file = readdir($handle))) {
$imageinfo = @getimagesize($file);
if(in_array($imageinfo["mime"], $allowed_mimes))
$imglist[] = $file;
}
closedir($handle);
}
$rand = rand(0,count($imglist)-1);
$file = $imglist[$rand];
$imageinfo = @getimagesize($file);
switch($imageinfo["mime"]) {
case "image/jpeg":
$image = imagecreatefromjpeg($file);
header("Content-type: image/jpeg");
imagejpeg($image);
break;
case "image/gif":
$image = imagecreatefromgif($file);
header("Content-type: image/gif");
imagegif($image);
break;
case "image/png":
$image = imagecreatefrompng($file);
imagealphablending($image,false);
imagesavealpha($image,true);
header("Content-type: image/png");
imagepng($image);
break;
}
imagedestroy($image);
?>
Tags: geshi, php, syntax highlighting, testing, wp-syntax
Posted in General | Comments(0)