php - Cut 1 big image into small images with the same size -



php - Cut 1 big image into small images with the same size -

given jpg image, cutting off in horizontal direction size of spic around 100k

any tips?

have used function in past works me...

this take input file , create tiles of specified size...

function maketiles($name, $imagefilename, $crop_width, $crop_height) { $dir = "source dir"; $slicesdir = "target dir"; // might check if $slicesdir exists etc if not create it. $inputfile = $dir . $imagefilename; $img = new imagick($inputfile); $imgheight = $img->getimageheight(); $imgwidth = $img->getimagewidth(); $cropwidthtimes = ceil($imgwidth/$crop_width); $cropheighttimes = ceil($imgheight/$crop_height); for($i = 0; $i < $cropwidthtimes; $i++) { for($j = 0; $j < $cropheighttimes; $j++) { $img = new imagick($inputfile); $x = ($i * $crop_width); $y = ($j * $crop_height); $img->cropimage($crop_width, $crop_height, $x, $y); $data = $img->getimageblob(); $newfilename = $slicesdir . $name . "_" . $x . "_" . $y . ".jpg"; $result = file_put_contents ($newfilename, $data); } } }

php image gd cut

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -