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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.