PHP - Resize an image and fill gaps of proportions with a color
Posted
by Kerry
on Stack Overflow
See other posts from Stack Overflow
or by Kerry
Published on 2010-06-16T05:41:25Z
Indexed on
2010/06/16
5:52 UTC
Read the original article
Hit count: 281
I am uploading logos to my system, and they need to fix in a 60x60 pixel box. I have all the code to resize it proportionately, and that's not a problem.
My 454x292px image becomes 60x38. The thing is, I need the picture to be 60x60, meaning I want to pad the top and bottom with white each (I can fill the rectangle with the color).
The theory is I create a white rectangle, 60x60, then I copy the image and resize it to 60x38 and put it in my white rectangle, starting 11px from the top (which adds up to the 22px of total padding that I need.
I would post my code but it's decently long, though I can if requested.
Does anyone know how to do this or can you point me to code/tutorial that does this?
© Stack Overflow or respective owner