首页 > 代码库 > PHP 图片 平均分割

PHP 图片 平均分割

$filename = ‘D://WWW/1.jpg‘;$p = 5;// Get new sizeslist($width, $height) = getimagesize($filename);$newwidth = $width;$newheight = floor($height / $p);$last = $height % $p;// Load$source = imagecreatefromjpeg($filename);for( $i=0 ; $i< $p; $i++ ){	$_p = $newheight*$i;	if( ( $i + 1 ) == $p )		$newheight += $last;	$thumb = ImageCreateTrueColor($newwidth, $newheight);	imagecopyresized( $thumb, $source, 0, 0, 0, $_p, $newwidth,  $height, $width, $height);	imagejpeg( $thumb , "./t{$i}.jpg" ,100);}

将图片平均分成几份。