note 75540 deleted from function.imagecreatefromjpeg by cmb

From: Date: Sun, 11 Dec 2016 11:10:30 +0000
Subject: note 75540 deleted from function.imagecreatefromjpeg by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208494@lists.php.net to get a copy of this message
Note Submitter: jhon at stockton dot com dot com ---- // 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); } } }

« previous php.notes (#208494) next »