在 (PHP/GD) 中调整图像大小
我正在寻求帮助/建议,以找到最有效的方法,使用 PHP/GD 将图像大小调整为尽可能小,同时保留原始图像的纵横比,但确保调整后的图像大于定义的最小宽度&高度。
例如,调整大小后的图像必须具有 宽度 >= 400 和高度 >= 300,但应尽可能接近这些尺寸,同时保持原始宽高比。
这样,“风景”图像的理想高度为 300 或稍大,宽度 >= 400,“肖像”图像的理想高度为 >宽度为 400 或稍大,高度 >= 300。
I'm looking for help/suggestions in finding the most efficient way to resize an image to be as small as possible using PHP/GD while preserving the aspect ratio of the original image but ensuring the the resized image is bigger than a defined minimum width & height.
For example, the resized image must have a width >= 400 and a height >= 300 but should be as close to those dimensions as possible while maintaining the original aspect ratio.
Such that a "landscape" image would have an ideal height of 300 or slightly larger with a width >= 400 and a "portrait" image would have an ideal width of 400 or slightly larger with a height >= 300.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信这就是您正在寻找的;具体来说,中间一列的图片:
以下代码源自 使用 ASP/PHP 裁剪以适合图像:
I believe this is what you're looking for; specifically, the pictures in the middle column:
Following code is derived from Crop-To-Fit an Image Using ASP/PHP:
这似乎完成了工作......
This seems to get the job done...