note 60472 deleted from function.imagecopyresampled by cmb

From: Date: Wed, 12 Oct 2016 15:52:19 +0000
Subject: note 60472 deleted from function.imagecopyresampled by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206863@lists.php.net to get a copy of this message
Note Submitter: com.hotmail@backglancer ---- wrote this for a game I was helping develop: Auto Tile Maker -- takes the image and cuts it in several smaller pieces, deleting the original... i mean.. this is just for those of you who are lazy, coz the script is simple.. modify at will. <? // $newfile is the full address of your newly uploaded file // $floc = is the location of that file ending with / // $t is the $_FILES['blah'] of your uploaded file. // whatever... you guys understand enough to modify this code $size = getimagesize($newfile); list($w, $h) = $size; if ($h > 20 || $w > 20) { $type = array_pop($size); switch ($type) { case 'image/jpeg' : $src_image = imagecreatefromjpeg($newfile); break; // insert more cases here :) i'm lazy too default : echo 'not an image!'; return; } $i = 0; for ($y = 0; $y < $h; $y += 20) { for ($x = 0; $x < $w; $x += 20) { $i++; // new file names will be like 1monkey.gif 2monkey.gif etc.. $new_image = imagecreatetruecolor(20, 20); imagecopyresampled ($new_image, $src_image, 0, 0, $x, $y, 20, 20, 20, 20 ); imagegif($new_image, $floc.$i.$t['name']); imagedestroy($new_image); } // x } // y unlink($newfile); } ?>

« previous php.notes (#206863) next »