note 75540 added to function.imagecreatefromjpeg

From: Date: Mon, 04 Jun 2007 20:02:37 +0000
Subject: note 75540 added to function.imagecreatefromjpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-127198@lists.php.net to get a copy of this message
// a function for resize the images(png,jpg,gif) in a directory //for the png you must have the zlib actived //$diror origin directory //$dirdest destination directory //$val value of resize(1,2,3..) //$qual quality(80 if you don't know) function imgres($diror,$dirdest,$val,$qual){ $q=$qual; //open the directory if (is_dir($diror)) { if ($dh = opendir($diror)) { while (($file = readdir($dh)) !== false) { if($file == "." || $file == ".."){continue;} $k=explode(".",$file); if(strpos($k[1],"jpg")===0 || strpos($k[1],"jpeg")===0){ $salva=$dirdest.$file; $image=$diror.$file; $im =imagecreatefromjpeg("$image"); $x=imagesx($im); $y=imagesy($im); $thumbnail=imagecreatetruecolor($x/$val,$y/$val); $im_ridimensionata=imagecopyresized( $thumbnail, $im, 0, 0, 0, 0, $x/$val, $y/$val, $x, $y); imagejpeg($thumbnail, $salva, $q); } elseif(strpos($k[1],"gif")===0){ $salva=$dirdest.$file; $image=$diror.$file; $im =imagecreatefromgif("$image"); $x=imagesx($im); $y=imagesy($im); $thumbnail=imagecreatetruecolor($x/$val,$y/$val); $im_ridimensionata=imagecopyresized( $thumbnail, $im, 0, 0, 0, 0, $x/$val, $y/$val, $x, $y); imagegif($thumbnail, $salva, $q); } elseif(strpos($k[1],"png")===0){ $salva=$dirdest.$file; $image=$diror.$file; $im =imagecreatefrompng("$image"); $x=imagesx($im); $y=imagesy($im); $thumbnail=imagecreatetruecolor($x/$val,$y/$val); $im_ridimensionata=imagecopyresized( $thumbnail, $im, 0, 0, 0, 0, $x/$val, $y/$val, $x, $y); imagepng($thumbnail, $salva, $q); } else{ echo "File not compatible(no jpg,gif or png)"; } } closedir($dh); } } } ---- Server IP: 69.147.83.197 Probable Submitter: 87.14.236.53 ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php Edit -- https://master.php.net/note/edit/75540 Del: integrated -- https://master.php.net/note/delete/75540/integrated Del: useless -- https://master.php.net/note/delete/75540/useless Del: bad code -- https://master.php.net/note/delete/75540/bad+code Del: spam -- https://master.php.net/note/delete/75540/spam Del: non-english -- https://master.php.net/note/delete/75540/non-english Del: in docs -- https://master.php.net/note/delete/75540/in+docs Del: other reasons-- https://master.php.net/note/delete/75540 Reject -- https://master.php.net/note/reject/75540 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127198) next »