$filename = ‘D://WWW/1.jpg‘; $p = 5; // Get new sizes list($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); }
将图片平均分成几份。
PHP 图片 平均分割
时间: 2024-10-19 15:24:12