Warning: imagecreatetruecolor(): Invalid image dimensions in r:\home\localhost\www\imgs\mini.php on line 64
Warning: imagecopyresized(): supplied argument is not a valid Image resource in r:\home\localhost\www\imgs\mini.php on line 66
Fatal error: Call to undefined function: imagegif() in r:\home\localhost\www\imgs\mini.php on line 36
<?php $img_type = null; function getImage($imgName) { if($ext == 'jpg'){ $img = imagecreatefromjpeg($imgName); $GLOBALS['img_type'] = IMG_JPEG; } else if($ext == 'gif'){ $img = imagecreatefromgif($imgName); $GLOBALS['img_type'] = IMG_GIF; } else if($ext == 'png'){ $img = imagecreatefrompng($imgName); $GLOBALS['img_type'] = IMG_PNG; } else{ $img = null; $GLOBALS['img_type'] = null; } return $img; } function saveImage($img, $name, $imgType) { $name = $name.\"-resized.\"; switch($imgType){ case IMG_JPEG: $name .= \"jpg\"; imagejpeg($img, $name); break; case IMG_GIF: $name .= \"gif\"; imagegif($img, $name); break; case IMG_PNG: $name .= \"png\"; imagepng($img, $name); break; } } function resize($imgName, $size) { if(!($img = getImage($imgName))){ return false; } $img_w = imagesx($img); $img_h = imagesy($img); $ration = $img_w / $img_h; if($ratio > 1){ $new_img_w = $size; $new_img_h = ($size / $ratio); } else{ $new_img_w = ($size * $ratio); $new_img_h = $size; } $tempImg = imagecreatetruecolor($new_img_w, $new_img_h); imagecopyresized($tempImg, $img, 0, 0, 0, 0, $new_img_w, $new_img_h, $img_w, $img_h); saveImage($tempImg, $imgName, $GLOBALS['img_type']); } resize(\"1.gif\", 100); ?>