'jpeg', 'image/gif' => 'gif', 'image/png' => 'jpg', 'image/png' => 'png', 'image/bmp' => 'bmp'); //RM Image types if ($image !== false) { $file = $imagePath . $image; if (!file_exists($file) and $default !== false) $file = 'image_not_found.jpg'; if (file_exsists($file) and is_readable($file)) { $info = getimagesize($file); if ($info !== false and isset($mimeTypes[$info['mime']]) and ($imageType = $mimeTypes[$info['mime']])) { if ($imageType == 'bmp') { require_once('bmp.php'); //RM this emalutes PHP like functions for bmp } $original = null; $evalCode = "\$original = imagecreatefrom$imageType(\$file);"; //RM Instead of if (type == 'jpeg') ImageCreateFromJPEG we use eval to cover all possibilities @eval($evalCode); if (@imagesx($original) !== false){ //RM Test if image resource is ok $width = ($width !== false) ? $width : imagesx($original); $height = ($height !== false) ? $height : imagesy($original); $newImage = imagecreatetruecolor($width, $height); //RM Output new image imagecopyresampled($newImage, $original, 0, 0, 0, 0, $width, $height, imagesx($original), imagesy($original)); header ("Content-type: image/jpeg"); @ImageJPEG ($newImage); exit; } } else { header("HTTP/1.0 404 Not Found"); echo 'wrong_picture_type.jpg'; } } } ?>