首页
开发手册
应用中心
工具
用户中心
FoundPHP 照片:缩放
中文简体
中文简体
English
上一篇
下一篇
#FoundPHP 照片:缩放 `框架下默认集成 FoundPHP_image 支持格式:jpg、jpeg、png、gif` `应用库地址:class/image/resize.php` `采用GD库php默认memory_limit是128M,如果需要处理大尺寸照片修改512M以上。` **采用缩放zoom的时候可以用xy定位,默认中间定位** | 左侧 | 中部 | 右侧 | | ------------ | ------------ | ------------ | | |
top(顶部)
| | | left(左边) |
center(居中)
| right(右边) | | |
bottom(底部)
| |
**图例:** ![](data/files/edit/20/05/03/200503_00152031.jpg) ###缩放照片居中补白背景色 ```php $FoundPHP_image->image('foundphp.jpg'); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/03/200503_00226073.jpg)
###居左缩放照片补红背景 ------------ 我们尝试定位左边,为了更明显我们设置了背景色#800000红色 ```php $FoundPHP_image->image('foundphp.jpg'); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'zoom' =>1, //按比例缩放 'xy' =>'left' //居左 'bgcolor' =>'#800000', )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/03/200503_00299146.jpg)
###按原始比例缩放,设置最大边长无背景填充 ------------ ```php $FoundPHP_image->image('foundphp.jpg'); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, 'lock' =>1, //0宽宽高不足填充颜色,1缩放照片最大宽度 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: 高度400宽度按比例缩放为300 ![](data/files/edit/20/05/05/200505_15541581.jpg)