10000) ){$make_magick = system($pref['im_path']."convert -quality ".strval(intval($im_quality)-20)." -antialias -geometry ".$new_size."x".$new_imageheight." ".$source_file." ".$destination_file, $retval);} $filename = $destination_file; $handle = fopen ($filename, "rb"); $contents = fread ($handle, filesize ($filename)); echo $contents; fclose ($handle); } }else if($mode == "gd1"){ if($image_stats[2] == 2) $src_img = imagecreatefromjpeg($source_file); else $src_img = imagecreatefrompng($source_file); if(!$src_img){ return FALSE; } $dst_img = imagecreate($new_size, $new_imageheight); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_size, $new_imageheight, $imagewidth, $imageheight); header("Content-type: image/jpeg"); imagejpeg($dst_img, $cachefilename, $im_quality); imagedestroy($src_img); imagedestroy($dst_img); }else if($mode == "gd2"){ if ($image_stats[2] == 2) $src_img = imagecreatefromjpeg($source_file); else $src_img = imagecreatefrompng($source_file); if (!$src_img){ return FALSE; } $dst_img = imagecreatetruecolor($new_size, $new_imageheight); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_size, $new_imageheight, $imagewidth, $imageheight); header("Content-type: image/jpeg"); imagejpeg($dst_img, $cachefilename, $im_quality); imagedestroy($src_img); imagedestroy($dst_img); } } $pref['im_quality']="70"; $pref['im_path']="/usr/bin/"; $pref['resize_method']="ImageMagick"; resize_image($ilink,$HTTP_GET_VARS["width"],getcwd().'/thumb/cache/'.$HTTP_GET_VARS["width"]."/".$cachefilename);exit; } else { header("Content-type: image/jpeg"); $filename = getcwd().'/thumb/cache/'.$HTTP_GET_VARS["width"]."/".$cachefilename; //if ((filesize($filename)>10000) ){$make_magick = system($pref['im_path']."mogrify -depth 16 $filename", $retval);} $handle = fopen ($filename, "rb"); $contents = fread ($handle, filesize ($filename)); echo $contents; fclose ($handle);exit; } $ilink=eregi_replace("(http://)[0-9\.]+/files","/home/webpages/files", $image); $ilink=eregi_replace("http://","",$ilink); $ilink=eregi_replace("207.44.240.34","/home/webpages/files",$ilink); // Specify your file details $current_file = $ilink; $max_width = '100'; // Get the current info on the file $current_size = getimagesize($current_file); $current_img_width = $current_size[0]; $current_img_height = $current_size[1]; $image_base = explode('.', $current_file); // This part gets the new thumbnail name $image_basename = $image_base[0]; $image_ext = $image_base[1]; $thumb_name = getcwd()."/thumb/cache/".$image_basename.'-th.'.$image_ext; // Determine if the image actually needs to be resized // and if it does, get the new height for it if ($current_img_width > $max_width) { $too_big_diff_ratio = $current_img_width/$max_width; $new_img_width = $max_width; $new_img_height = round($current_img_height/$too_big_diff_ratio); // Convert the file $make_magick = system("/usr/bin/convert -geometry $new_img_width x $ new_img_height $current_file $thumb_name", $retval); echo "/usr/bin/convert -geometry $new_img_width x $ new_img_height $current_file $thumb_name"; // Did it work? if (!($retval)) { echo 'Thumbnail created: '; } else { echo 'Error: Please try again.'; } } else { echo 'No need to resize.'; } exit; $lakap_link= $ilink; $lakap_link_cache=ereg_replace("/","_",$lakap_link); $lakap_link_cache=ereg_replace("-","_",$lakap_link_cache); $lakap_link_cache=ereg_replace(":","_",$lakap_link_cache); //$lakap_link_cache=ereg_replace("\.","_",$lakap_link_cache); $lakap_link_cache=substr($lakap_link_cache,-50); //$lakap_link_cache=$lakap_link_cache; require_once "thumb/class.thumbnail.php"; $img = new Thumbnail(); $wtd=getimagesize ($ilink); $img->thumbnail_dir_internal = getcwd().'/thumb/cache/'.$HTTP_GET_VARS["width"]; $img->thumbnail_dir_external = 'thumb/cache/'.$HTTP_GET_VARS["width"]; $img->max_width = $HTTP_GET_VARS["width"]; //echo intval($wtd[0]);exit; if (intval($wtd[0])<$img->max_width) {$img->max_width=intval($wtd[0]);} //$img->max_height = 300; $img->create( $ilink,$lakap_link_cache); $image = fopen ( $img->thumbnail_dir_internal."/".$lakap_link_cache, "rb"); fpassthru ($image); fclose ($image); //echo 'Preview (' . $img->image_name . '):
' .$img->image_tag; exit; //if (!file_exists($lakap_link_cache)) //{ error_reporting(0); $types = array (1 => "gif", "jpeg", "png", "swf", "psd", "wbmp"); if ($ext=="jpg"){$ext="jpeg";} //echo $lakap_link_cache;exit; //Header ("Content-Type: image/".$ext); // header ("Content-type: image/jpeg"); # We will create an *.jpg //= imagecreatefromjpeg($image) or die ("Image not found!"); $pic = @call_user_func("imagecreatefrom".$ext, $ilink); if ($pic) { $width = imagesx($pic); $height = imagesy($pic); $twidth = $HTTP_GET_VARS["width"]; # width of the thumb 160 pixel $theight = $twidth * $height / $width; # calculate height $thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Can't create Image!"); imagecopyresized($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width, $height); # resize image into thumb ImageJPEG($thumb,$lakap_link_cache,75); # Thumbnail as JPEG // call_user_func("image".$ext, $thumb, $lakap_link_cache); //echo $lakap_link_cache;exit; $image = fopen ($lakap_link_cache, "rb"); fpassthru ($image); fclose ($image); } else { $image = fopen ($ilink, "rb"); fpassthru ($image); fclose ($image); } //} //else //{ //$image = fopen ($lakap_link_cache, "rb"); // fpassthru ($image); // fclose ($image); //} ?>