Sim Posted February 25, 2009 Share Posted February 25, 2009 I'm trying to take an image and extract every 32x32 image from it. heres what I got. every image i upload is divisible by 32 so I know thats not the problem. ever image I uploaded gets created as preview.png so i know thats not the problem either. mkdir("../tiles/$names", 0777); $file_typ = array(); $file_typ = explode('.',strtolower($_FILES["file"]["name"])); $file_type = $file_typ[count($file_typ)-1]; if($file_type == "png") { move_uploaded_file($_FILES["file"]["tmp_name"], "../tiles/$names/preview.png"); $src = imagecreatefrompng("../tiles/$names/preview.png"); $w = imagesx($src) / 32; $h = imagesy($src) / 32; if( (is_int($w)) && (is_int($h)) ) { /* Create a blank image */ for($x=0; $x < $h - 32; $x=$x+32) { for($y=0; $y < $w - 32; $y=$y+32) { $im = imagecreate(32, 32); imagecopymerge($im $src, 0, 0, $x,$y, $x+32, $y + 32, 0); imagepng($im ,"../tiles/$names/$x-$y.png"); } } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.