1 <?php 2 3 /** 4 * 图像裁剪 5 * @param $source_path 原图路径 6 * @param $target_width 需要裁剪的宽 7 * @param $target_height 需要裁剪的高 8 * @return bool 9 */ 10 function imagecropper($source_path, $target_width, $target_height) 11 { 12 $source_info = getimagesize($source_path); 13 $source_width = $source_info[0]; 14 $source_height = $source_info[1]; 15 $source_mime = $source_info['mime']; 16 $source_ratio = $source_height / $source_width; 17 $target_ratio = $target_height / $target_width; 18 19 // 源图过高 20 if ($source_ratio > $target_ratio) { 21 $cropped_width = $source_width; 22 $cropped_height = $source_width * $target_ratio; 23 $source_x = 0<
php 图片剪切
于 2017-07-03 15:58:21 首次发布

最低0.47元/天 解锁文章
702

被折叠的 条评论
为什么被折叠?



