Jump to content

How to keep a photos aspect ratio but keep it in a minimum size (320x200)?


cs.punk

Recommended Posts

I can't figure out a good way of showing my users profile pictures in a minimum size of example 320x200,but to keep the aspect ratio intact and maybe user 'blocks' to fill out the empty space.(i've attached a image example'

 

How do you deal with it?

 

Secondly, with each photo being up to 2MB in size, is there a way to load the '320x200' image only rather than a 'squashed' image of the full image? I use the following code:

 

<img src='../file_uploads/$profile_pic' height='320' width='200'/>

 

[attachment deleted by admin]

You can't do this with HTML. You need to use a serverside language like php to resize the picture on upload, and display it that way. And in fact that's definitely what you should do, because if you are showing the user a 'squashed' version of the image, your web pages are going to take significantly longer to download than they need to, as the user will be downloading images larger than they are actually seeing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.