Resizing and cropping image with GD while retaining aspect ratio

与世无争的帅哥 提交于 2019-12-05 11:43:53

There is more than one way to resize an image. I'll spell them out for you:

  • Stretch to fit -- the image is resized to the desired size ignoring aspect ratio
  • Scale to fit -- the image is resized so that one dimension (width or height) has the desired size while the other is same or shorter while maintaining aspect ratio (one extra step may be required to fill the shorter side with solid color)
  • Crop to fit -- the image is resized so that one dimension (width or height) has the desired size while the other is same or longer while maintaining aspect ratio (one extra step is required to trim the outside region)

PS: both articles were written by me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!