How to restrict image width or height on upload

后端 未结 3 1105
一生所求
一生所求 2021-01-16 05:03

I would like manipulate/resize images in a similar way to Pinterest but I am not sure what is the best way to approach it. The goal is to allow a mix of both portrait and la

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 05:44

    You just need to understand which of the two edges of the image is longer, and compute the other dimension proportionally. If the maximum long-egde is 1024, then if one of the two edges is larger you will set that to 1024, and compute the other to fit the proportions. Then you will pass those two values to your image management functions.

    Like here: http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

    Or here: http://www.9lessons.info/2009/03/upload-and-resize-image-with-php.html

提交回复
热议问题