Page 1 of 1

Images scratched

Posted: Tue Sep 02, 2008 11:10 am
by m2babaey
Hi
I use this code to show images ( image name from database )

Code: Select all

<img src=”image1.jpg” width=250 height=250>
With this code, if the image size is 250 * 200 it will be scratched to fit the square.
What is the solution?
thanks

Re: Images scratched

Posted: Tue Sep 02, 2008 12:54 pm
by andyhoneycutt
I think you mean the image will be stretched? You could do some math in your php to get the image dimensions. Once you figure out x and y of the image you can build a ratio to derive the proper sizes. Check out gd lib (On php.net)

-Andy

Re: Images scratched

Posted: Tue Sep 02, 2008 2:03 pm
by kaszu
Other solution is remove "width=250 height=250" then it will be in the original size or just remove "height=250", then it will be stretched to width 250px and height will be calculated automatically by browser.