S
S
Sergey Semenko2014-10-20 17:03:58
PHP
Sergey Semenko, 2014-10-20 17:03:58

How to make a square image preview in PHP?

You need to do like here with the authors, for example, I upload an image of 500x250, and I get 256x256 (or any other size, for example, 64x64)
Original image
34da93fc716a4b4eaa7a500be9486135.jpg
And this is what we get
cfdbc94200514829aed69620f7897a69.jpg
UPD.
If the height of the image is greater than the width, the length of the square is equal to the width, and if the width is greater, the length is equal to the height, and then the whole thing is increased or reduced to the desired size.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pi314, 2014-10-20
@abler98

For example, use imagecopyresampled() .
To pre-determine the size of the original (and then find the maximum square area), you can use getimagesize() .
All business running around - 10~15 lines of code :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question