Images scratched

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Images scratched

Post 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
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Images scratched

Post 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
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Images scratched

Post 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.
Post Reply