查看文件: re.php
大小: 3.77 KB
类型: application/octet-stream
<? $pic ='/www2/skybni/ecard/img/user_0000113.jpeg'; $apic ='/www2/skybni/ecard/reimg/user_123.jpg'; $source='/www2/skybni/ecard/img/user_0000123.jpg'; $repic3a ='/www2/skybni/ecard/reimg/user_0000123a.jpg'; $repic3b ='/www2/skybni/ecard/reimg/user_0000123xxxx.jpg'; // $syscall_3b="/usr/local/bin/convert $pic -resize 200x200 -size 200x200 xc:white +swap -gravity center -composite $repic3b"; // $syscall_3b="/usr/local/bin/convert $pic -resize \"20x20^\" -gravity Center -crop 120x120+0+0 $repic3b"; // $syscall_3b="/usr/local/bin/convert $pic -adaptive-resize 200x200 $repic3b"; // echo $syscall_3a; // //$output1=`$syscall_3a`; $syscall_3b="/usr/local/bin/convert $pic -thumbnail \"220x220^\" -gravity Center 220x220 $repic3b"; //$syscall_3b="/usr/local/bin/convert $pic -adaptive 220x220 $repic3b"; //$syscall_3b="/usr/local/bin/convert $pic -adaptive-resize geometry 220x220 -gravity $repic3a"; // $syscall_3b="/usr/local/bin/convert $pic -resize 300x300 -gravity $repic3b"; echo $syscall_3b; $output1=`$syscall_3b`; /* $x=288; $y=202; // my final thumb $ratio_thumb=$x/$y; // ratio thumb list($xx, $yy) = getimagesize($source); // original size $ratio_original=$xx/$yy; // ratio original if ($ratio_original>=$ratio_thumb) { $yo=$yy; $xo=ceil(($yo*$x)/$y); $xo_ini=ceil(($xx-$xo)/2); $xy_ini=0; } else { $xo=$xx; $yo=ceil(($xo*$y)/$x); $xy_ini=ceil(($yy-$yo)/2); $xo_ini=0; } imagecopyresampled($thumb, $source, 0, 0, $xo_ini, $xy_ini, $x, $y, $xo, $yo); */ /** * 图片缩放函数(可设置高度固定,宽度固定或者最大宽高,支持gif/jpg/png三种类型) * Author : Specs * Homepage: https://9iphp.com * * @param string $source_path 源图片 * @param int $target_width 目标宽度 * @param int $target_height 目标高度 * @param string $fixed_orig 锁定宽高(可选参数 width、height或者空值) * @return string */ /* function myImageResize($source_path, $target_width = 200, $target_height = 200, $fixed_orig = ''){ $source_info = getimagesize($source_path); $source_width = $source_info[0]; $source_height = $source_info[1]; $source_mime = $source_info['mime']; $ratio_orig = $source_width / $source_height; if ($fixed_orig == 'width'){ //宽度固定 $target_height = $target_width / $ratio_orig; }elseif ($fixed_orig == 'height'){ //高度固定 $target_width = $target_height * $ratio_orig; }else{ //最大宽或最大高 if ($target_width / $target_height > $ratio_orig){ $target_width = $target_height * $ratio_orig; }else{ $target_height = $target_width / $ratio_orig; } } switch ($source_mime){ case 'image/gif': $source_image = imagecreatefromgif($source_path); break; case 'image/jpeg': $source_image = imagecreatefromjpeg($source_path); break; case 'image/png': $source_image = imagecreatefrompng($source_path); break; default: return false; break; } $target_image = imagecreatetruecolor($target_width, $target_height); imagecopyresampled($target_image, $source_image, 0, 0, 0, 0, $target_width, $target_height, $source_width, $source_height); //header('Content-type: image/jpeg'); $imgArr = explode('.', $source_path); $target_path = $imgArr[0] . '_new.' . $imgArr[1]; imagejpeg($target_image, $target_path, 100); } //myImageResize($apic, 200, 200); //最大宽高 myImageResize($apic, 200, 200, 'width'); //宽度固定 //myImageResize($apic, 200, 200, 'height'); //高度固定 */ ?>
保存
取消
返回文件列表