12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- $dirpath = './items/src';
- $return = [];
- $files = array();
- $dir = opendir($dirpath); // open the cwd..also do an err check.
- while(false != ($file = readdir($dir))) {
- if(($file != ".") and ($file != "..") and ($file != "index.php")) { $files[] = $file; }
- }
- natsort($files);
- $item_id = 0;
- $rows = 6;
- $cols = 6;
- foreach($files as $file) {
- $src = imagecreatefrompng('./items/src/'.$file);
- for($r = 0; $r < $rows; $r++) {
- for($c = 0; $c < $cols; $c++) {
- $dest = imagecreatetruecolor(42,42);
- imagesavealpha($dest, true);
- $trans_color = imagecolorallocatealpha($dest, 0, 0, 0, 127);
- imagefill($dest, 0, 0, $trans_color);
- imagecopy($dest, $src, 0,0, ($c*42), ($r*42), 42, 42);
- imagepng($dest, './items/out/'.$item_id.'.png');
- imagedestroy($dest);
- $item_id++;
- }
- }
- imagedestroy($src);
- }
-
-
- echo'<pre>'.print_r($return,1).'</pre>';
-
-
- ?>
|