mam tento kod a neviem kde mam chybu na localhoste mi to ide ok ale na serveri mi vyhadzuje varovanie ze sa neda otvorit subor do ktoreho sa ma zapisat obrazok ....
Kód:
<?
$IMG_ORG_HEIGHT = "*";
$IMG_ORG_WIDTH = "*";
$IMG_HEIGHT = "450";
$IMG_WIDTH = "450";
$IMG_ROOT = "./";
$use_imagecreatetruecolor = true;
$use_imagecopyresampled = true;
$JPG_QUALITY = 80;
if(!$f_res = resizer_main("images/c.jpg","_",$IMG_WIDTH,$IMG_HEIGHT))die("error");
$fs_org= filesize("$IMG_ROOT/$f_org" );
$html =<<< EHTML
<img src="$IMG_ROOT/$f_res" $sz_res[3]>
EHTML;
echo $html;
function resizer_main($image, $prefix, $w, $h){
global $use_imagecreatetruecolor, $use_imagecopyresampled, $IMG_ROOT,
$JPG_QUALITY, $HTTP_POST_FILES;
$image_name = "dsdsaa.jpg";
//$image = "nick.JPG";
if(trim($image) == "" || trim($image) =="none") return false;
$arr_img = imagecreatefromgd2($image);
if( $arr_img["w"] != $w && $arr_img["h"] != $h){
$wh = get_sizes($arr_img["w"], $arr_img["h"], $w, $h);
$img_res = img_get_resized($arr_img["img"], $arr_img["w"], $arr_img["h"], $wh["w"], $wh["h"], $use_imagecreatetruecolor, $use_imagecopyresampled);
} else {
$img_res = $arr_img["img"];
}
$file_name = "dddd.gif";
//$file_name = make_filename($image_name, $prefix);
imagegif($img_res, $IMG_ROOT.$prefix.$file_name, $JPG_QUALITY);
return $prefix."".$file_name."";
}
function image_from_upload($uploaded_file){
$img_sz = getimagesize( $uploaded_file );switch( $img_sz[2] ){
case 1:
$img_type = "GIF";
die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
break;
case 2:
$img = ImageCreateFromJpeg($uploaded_file);
$img_type = "JPG";
break;
case 3:
$img = ImageCreateFromPng($uploaded_file);
$img_type = "PNG";
break;
case 4:
$img_type = "SWF";
die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
break;
default: die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
}
return array("img"=>$img, "w"=>$img_sz[0], "h"=>$img_sz[1], "type"=>$img_sz[2], "html"=>$img_sz[3]);
}
function get_sizes($src_w, $src_h, $dst_w,$dst_h ){
$mlt_w = $dst_w / $src_w;
$mlt_h = $dst_h / $src_h;
$mlt = $mlt_w < $mlt_h ? $mlt_w:$mlt_h;
if($dst_w == "*") $mlt = $mlt_h;
if($dst_h == "*") $mlt = $mlt_w;
if($dst_w == "*" && $dst_h == "*") $mlt=1;
$img_new_w = round($src_w * $mlt);
$img_new_h = round($src_h * $mlt);
return array("w" => $img_new_w, "h" => $img_new_h, "mlt_w"=>$mlt_w, "mlt_h"=>$mlt_h, "mlt"=>$mlt);
}
function
img_get_resized($img_original,$img_w,$img_h,$img_new_w,$img_new_h,$use_imagecreatetruecolor=false,
$use_imagecopyresampled=false){
if( $use_imagecreatetruecolor &&
function_exists("imagecreatetruecolor")){
$img_resized = imagecreatetruecolor($img_new_w,$img_new_h) or
die("<br><font color=\"red\"><b>Failed to create destination image.</b></font><br>");
} else {
$img_resized = imagecreate($img_new_w,$img_new_h) or
die("<br><font color=\"red\"><b>Failed to create destination image.</b></font><br>");
}
if($use_imagecopyresampled && function_exists("imagecopyresampled")){
imagecopyresampled($img_resized, $img_original, 0, 0, 0, 0,$img_new_w, $img_new_h, $img_w,$img_h) or die("<br><font color=\"red\"><b>Failed to resize @ ImageCopyResampled()</b></font><br>");
}else{
imagecopyresized($img_resized, $img_original, 0, 0, 0, 0,$img_new_w, $img_new_h, $img_w,$img_h) or die("<br><font color=\"red\"><b>Failed to resize @ ImageCopyResized()</b></font><br>");
}
return $img_resized;
}
function make_filename($image_name){
$file_name = uniqid('s').'.jpg';
$pos = strrpos($file_name, '.');
$file_name = substr($file_name, 0,$pos).".jpg";
return $file_name;
}
?>