调整图像大小以完美适合确定的框
我想要执行以下操作:
- 我需要调整图像大小以适合并填充 100x100 像素框
并非所有图像都是完美的正方形,这就是我这项任务的问题- 我想确定哪一边(宽度或高度)最小。
- 将该边缩小到 100 像素;中后卫
- 裁剪两侧的溢出
我已经尝试过宽度/高度:100% 技术,但这并没有给出我想要的结果(它被拉伸并且丑陋)。我还看到了一些方法,但是在 C# 中......我需要在 PHP 中。
我将不胜感激任何建议、指示、输入或准备好的脚本...... 感谢
使用 PHP 5.3.0
I want to do the following :
- I need to resize images to fit and fill enterly 100x100 pixel box
not all image are perfect squares, and thats my problem for this task- I want to determine wich side (width or height) is the smallest.
- Bring that Side to 100px while scaling down; Center back
- Crop the overflow on both side
I've tried the width/height :100% technic but that doesnt give the result i want, (it is streched and ugly). Also i've seen some method but in C# ... I need in PHP.
I would appreciate any advice, directions, input, or ready script...
Thanks
using PHP 5.3.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须能够通过事先了解图像尺寸来计算纵横比。更多信息请参见 getimagesize()
之后就可以得到缩小后的高度在
$height
中,缩小后的宽度将在$width
中可用。You must be able to calculate the aspect ratio by knowing the image dimensions beforehand. For more info, see getimagesize()
Afterwards, the scaled down height will be available in
$height
and the scaled down width will be available in$width
.