给定图像和纵横比的最大裁剪区域
有没有 PHP/GD 函数可以计算这个:
输入:图像宽度、图像高度和要遵循的纵横比。输出: 尊重给定纵横比的最大居中裁剪的宽度/高度 (尽管图像原始长宽比)。
示例:图像为 1000x500,ar 为 1.25:最大裁剪为 625x500。图像为 100x110,最大裁剪为:80x110。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有函数可以计算此值,因为它是初等数学:
查看实际操作。
There is no function that calculates this because it's elementary math:
See it in action.
作为 @Jon 的 答案,这里是 PHP-GD 库
As an extension to @Jon's answer, here's an implementation of this approach in PHP-GD library