Autor | Zpráva | ||
---|---|---|---|
Cyva Profil |
#1 · Zasláno: 7. 10. 2006, 12:38:00
Mohl by mi prosim někdo poradit? Je velikost obrázků ( JPEG, PNG ) při spracování GD knihovnou nějak omezena? Jelikož mi fce viz. nadpis nechce zpracovávat větší obrázky než cca 0.5MB a nějaké funkce k tomu ( max. velikost spracování, nastavení max. velikosti spracování ). Díky.
|
||
Cyva Profil |
#2 · Zasláno: 7. 10. 2006, 12:39:10
Pardon Fce: ImageCreateFromJPEG, ImageCreateFromPNG. Hloupá chyba.
|
||
Alphard Profil |
#3 · Zasláno: 7. 10. 2006, 12:43:08
hosting může omezit prostředky a větší obrázky samozdřejmě chtějí více výkonu
|
||
Cyva Profil |
#4 · Zasláno: 7. 10. 2006, 12:56:13
A existují nějaké fce k zjištění těchto omezení?
|
||
peta Profil * |
#5 · Zasláno: 7. 10. 2006, 20:35:48
<input type="hidden" value="<?=$MAX_SIZE?>" name="MAX_FILE_SIZE"/>
$file = array(); $file = isset($_FILES[$a])?$_FILES[$a]: (isset($HTTP_POST_FILES[$a])?$HTTP_POST_FILES[$a]:""); $fileOk = fileCheck($file); if ($fileOk===1) { $photo1 = $file['tmp_name']; $size1 = $file['size']; $type1 = $FILE_MIMES[$file['type']]; ... } <?php $FILE_MIMES = array('image/pjpeg'=>"jpg",'image/jpeg'=>"jpg",'image/jpg'=>"jpg",'ima ge/png'=>"png",'image/x-png'=>"png",'image/gif'=>"gif",'image/bmp'=>"b mp"); $FILE_EXTS = array('.jpeg','.jpg','.png','.gif','.bmp'); $MAX_SIZE = 2097152; //asi 2M //=== check file === function fileCheck($file) { global $FILE_MIMES,$FILE_EXTS,$MAX_SIZE; $fileOK = 0; if (is_array($file)) $fileOK = 33; //name if (is_array($file) && $file['name']!=="" && File_Exists($file['tmp_name'])) { $fileOK = 2; //size if (is_uploaded_file($file['tmp_name']) && $file['size']<$MAX_SIZE) { $fileOK = 3; $file_ext = strtolower(substr($file['name'],strrpos($file['name'],"."))); if (array_key_exists($file['type'],$FILE_MIMES) && in_array($file_ext,$FILE_EXTS) ) //type,ext { $fileOK = 1; } } } return $fileOK; } // === img transform === function PPimageTransform($photo1,$type1,$dim,$crop,$format,$methode,$photo2,$t ype2) { /* need GD library (first PHP line: WIN dl("php_gd.dll"); UNIX dl("gd.so"); www.boutell.com/gd/ interval.cz/clanky/php-skript-pro-generovani-galerie-obrazku-2/ cz2.php.net/imagecopyresampled cz2.php.net/GetImageSize www.linuxsoft.cz/sw_detail.php?id_item=871 www.webtip.cz/art/wt_tech_php/liquid_ir.html */ $ok = 0;/*obrazek neumim zpracovat*/ if ($photo1!=="" && File_Exists($photo1)) { if (!($crop>0 && $crop<5)) {$crop = 0;} // get width, height list($w,$h) = GetImageSize($photo1); //array = width, height, type (gif), (string) "height=x width=x" $w = ($w<1)?1:$w; $h = ($h<1)?1:$h; $wh= $w/$h; // set format switch($format) { case '4/3': $format = 4/3; break; default : $format = 1; break; } // set auto crop if ($crop==0) { $z1 = $format- ($format-1)/2; $z2 = $format+(1-$format-1)/2; if ($wh>$z1) {$crop = 1;} elseif ($wh<$z2) {$crop = 2;} else {$crop = 3;} } // scale,nw,nh if ($crop==4) { $a=$w>$h?$w:$h; $scale=$dim/$a; $nw=$w*$scale; $nw=($nw<1)?1:$nw; $nh=$h*$scale; $nh=($nh<1)?1:$nh; // crop $d=array(0,0,floor($nw),floor($nh)); $s=array(0,0,$w,$h); } else { if ($crop==3) {$nw=1;$nh=1;} elseif ($crop==2) {$nw=1/$format;$nh=1;} elseif ($crop==1) {$nw=1;$nh=1/$format;} $nw*=$dim; $nw=($nw<1)?1:$nw; $nh*=$dim; $nh=($nh<1)?1:$nh; $s1=$nw/$w; $s2=$nh/$h; $h1=$nh*$s1; $w2=$nw*$s2; $s1=($h1<=$nh)?$s1:0; $s2=($w2<=$nw)?$s2:0; $scale=($s1>$s2)?$s1:$s2; $scale=($scale<=0)?1:$scale; // crop $d=array(0,0,floor($nw),floor($nh)); $x1=floor(($w-$d[2]/$scale)/2);$x1=$x1<0?0:$x1; $y1=floor(($h-$d[3]/$scale)/2);$y1=$y1<0?0:$y1; $s=array($x1,$y1,floor($w-2*$x1),floor($h-2*$y1)); } //print_r($s); //print_r($d); // set type input/output switch($type1) { case 'png': $x = "ImageCreateFromPNG"; $imgIn = function_exists($x) ? $x : -1; break; case 'jpg': $x = "ImageCreateFromJPEG"; $imgIn = function_exists($x) ? $x : -1; break; case 'gif': $x = "ImageCreateFromGIF"; $imgIn = function_exists($x) ? $x : -1; break; case 'bmp': $x = "ImageCreateFromWBMP"; $imgIn = function_exists($x) ? $x : -1; break; case 'xbm': $x = "ImageCreateFromXBM"; $imgIn = function_exists($x) ? $x : -1; break; case 'xpm': $x = "ImageCreateFromXPM"; $imgIn = function_exists($x) ? $x : -1; break; default: return FALSE; break; } if ($imgIn!=-1) { switch($type2) { case 'jpg': $x = "ImageJPEG"; $imgOut = function_exists($x) ? $x : -1; break; case 'png': $x = "ImagePNG"; $imgOut = function_exists($x) ? $x : -1; break; case 'gif': $x = "ImageGIF"; $imgOut = function_exists($x) ? $x : -1; break; case 'bmp': $x = "ImageWBMP"; $imgOut = function_exists($x) ? $x : -1; break; case 'xbm': $x = "ImageXBM"; $imgOut = function_exists($x) ? $x : -1; break; default: return FALSE; break; } if ($imgOut!=-1) { // Content type //header('Content-type: image/jpeg'); // Resample (d-destination, s-source) if (@$image1 = $imgIn($photo1)) { if ($methode==0) { $transf1 = ImageCreateTruecolor; $transf2 = ImageCopyResampled; } else { $transf1 = ImageCreate; $transf2 = ImageCopyResized; } $image2 = $transf1($d[2],$d[3]); $transf2($image2, $image1, $d[0],$d[1], $s[0],$s[1], $d[2],$d[3], $s[2],$s[3]); // Output if ($type2=='jpg' || $type2=='png') {$imgOut($image2,$photo2,85);} // save image, jpg/png quality else {$imgOut($image2,$photo2);} // save image ImageDestroy($image2); // free mem image2 ImageDestroy($image1); // free mem image1 $ok = 1; } } } } return $ok; } /* 's_imgDimension'=>array("rozmer",array( "80", "320", "640", "800" )), 's_imgCrop' =>array("oriznuti",array( "- auto -", "na sirku", "na vysku", "ctverec", "- zadne -" )), 's_imgFormat' =>array("format",array( "4/3", "1/1" )), 's_imgType' =>array("vystup",array( "jpg", "png", "gif", "bmp" )), 's_imgMethode' =>array("metoda",array( "resample", "resize" )) */ |
||
peta Profil * |
#6 · Zasláno: 7. 10. 2006, 20:37:17
Cyva
Cili ja to omezuji na 130k a typ JPG jinak obrazek transformuji pomoci transformace a to klidne i z 2M. Ze ti to omezuje hosting, a pravdepodobne jakykoliv soubor, za to ja nemuzu. |
||
Časová prodleva: 18 let
|
Toto téma je uzamčeno. Odpověď nelze zaslat.
0