600) $maxwidth=300; if ($maxheight<80 || $maxheight>900) $maxheight=500; $sql = ""; $image_path = ""; $field_name = ""; if ($item_id) { if (strtolower($type) == "small") { $field_name = "small_image";} elseif (strtolower($type) == "big") {$field_name = "big_image";} elseif (strtolower($type) == "super") {$field_name = "super_image";} if (strlen($field_name)) { $sql = " SELECT " . $field_name . " FROM " . $table_prefix . "items "; $sql .= " WHERE item_id=" . $db->tosql($item_id, INTEGER); } } if (strlen($sql)) { $db->query($sql); if ($db->next_record()) { $image_path = $db->f($field_name); } } $im_out = @imagecreatetruecolor(100,80); imagefill($im_out,1,1,imagecolorallocate($im_out,200,200,200)); if (strlen($image_path) && !preg_match("/^http\:/", $image_path)) { $image_extenison=""; if(preg_match("/\.gif$/", $image_path)) { $image_extension="gif"; } else if(preg_match("/\.png$/", $image_path)) { $image_extension="png"; } else if(preg_match("/\.jpg$/", $image_path)){ $image_extension="jpg"; } else if(preg_match("/\.jpg$/", $image_path)){ $image_extension="jpg"; } if (strlen($image_extension)) { switch ($image_extension) { case "gif": $im = imagecreatefromgif($image_path);break; case "png": $im = imagecreatefrompng($image_path);break; case "jpg": $im = imagecreatefromjpeg($image_path);break; } if ($im) { $image_error=false; $image_width=imagesx($im); $image_height=imagesy($im); if ($image_height>0) $image_ratio = $image_width/$image_height; $scale=1; if ($image_width>$maxwidth) $scale*=$maxwidth/$image_width; if ($image_height*$scale>$maxheight && $scale<1) $scale*=$maxheight/$image_height/$scale; $image_width_out = $image_width*$scale; $image_height_out = $image_height*$scale; $im_out = imagecreatetruecolor($image_width_out,$image_height_out); imagecopyresized($im_out,$im,0,0,0,0,$image_width_out,$image_height_out,$image_width,$image_height); } } } if (!isset($im)) { $im = imagecreatefromgif("images/mamod/no_image.gif"); imagecopy($im_out,$im,0,0,0,0,100,80); header("Content-Type: image/jpeg"); imagegif($im_out); } else { header("Content-Type: image/jpeg"); imagejpeg($im_out); } imagedestroy($im); imagedestroy($im_out); exit; ?>