note 41397 deleted from function.imagecopyresampled by nlopess

From: Date: Fri, 09 Apr 2004 11:51:07 +0000
Subject: note 41397 deleted from function.imagecopyresampled by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-67874@lists.php.net to get a copy of this message
Note Submitter: jeroen -at- trappers.be.tf ---- I adapted a the function above, so that sqare thumbs would be generated given a certain number. enjoy. function image_createSqareThumb($src,$dest,$zijde,$quality=100) { if (file_exists($src) && isset($dest)) { // path info $destInfo = pathInfo($dest); // image src size $srcSize = getImageSize($src); $srcRatio = $srcSize[0]/$srcSize[1]; // width/height ratio if ($srcRatio >= 1) { $destSize[1] = $zijde; //smallest side becomes $zijde $destSize[0] = $zijde*$srcRatio; //other side is enlarged } else { $destSize[0] = $zijde; //smallest side becomse $zijde $destSize[1] = $zijde/$srcRatio; //other side is enlarged } // path rectification if ($destInfo['extension'] == "gif") { $dest = substr_replace($dest, 'jpg', -3); } // true color image, with anti-aliasing $destImage = imageCreateTrueColor($zijde,$zijde); imageAntiAlias($destImage,true); // src image switch ($srcSize[2]) { case 1: //GIF $srcImage = imageCreateFromGif($src); break; case 2: //JPEG $srcImage = imageCreateFromJpeg($src); break; case 3: //PNG $srcImage = imageCreateFromPng($src); break; default: return false; break; } // resampling if ($srcRatio >= 1) { //when width>height : cut of piece left and right imageCopyResampled($destImage, $srcImage, -($destSize[0]-$zijde)/2, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); } else { //when width<height : cut of a piece on top and bottom imageCopyResampled($destImage, $srcImage, 0, -($destSize[1]-$zijde)/2, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); } // generating image switch ($srcSize[2]) { case 1: case 2: imageJpeg($destImage,$dest,$quality); break; case 3: imagePng($destImage,$dest); break; } return true; } else { return false; } }

« previous php.notes (#67874) next »