This code cuts only: 1, 2, 3 part. If you add another 1 for loop, trim comes from the other end.
$file = "testing3.png"; $size = getimagesize($file); $im = imagecreatefrompng($file); $newIm = imagecreatetruecolor(64, 64); $i = 1; for($y = $size[1] - 64; $y >= 0; $y = $y - 64){ imagecopy($newIm, $im, 0, 0, 0, $y, 64, 64); imagepng($newIm, "cut/" . $i++ . '.png'); } 