简体   繁体   中英

PHP image resize ratio issue

Php thumb resize image based on provided width and height, I am working on profile image which is: 130x130

While users are uploading image of long heights(rectangle) which leads to strecthed image in its width and when uploading long width image(rectangle) then strecthed, I hope you understand what I mean. Because when anyone uses a large square image it resize to correct 130x130 but longer width and height get strecthed.

I am thinking of having a good suggestion or idea to work around such images, either crop them from top to make them perfect square first.

Thanks, Najm.

Usually you will take the longer side, scale it up and scale the shorter side by the same percentage. One such snippet is here . You can also prefill the canvas with a smooth background that fits with your overall design.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM