justnajm
justnajm

Reputation: 4534

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.

Upvotes: 0

Views: 347

Answers (1)

Mirko Adari
Mirko Adari

Reputation: 5103

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.

Upvotes: 1

Related Questions