• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

ASP.NET

Anyone have a tool that I can use to set aspect ratios on images for uplaods?  I'm getting stretched vertical mimages.
0
lrbrister
Asked:
lrbrister
  • 2
  • 2
1 Solution
 
naspinskiCommented:
If you only specify a width, the height of an img will adjust properly.  You just have to make sure no height is declared.
0
 
lrbristerAuthor Commented:
naspinski

Is there a way to look at the image on submit and determine if it's a landscape or portrait and then set the width or height based on that?
0
 
naspinskiCommented:
Never thought of that, but turns out it is pretty easy.  You just have to use the System.Drawing.Bitmap object:
//this just represent getting your image into a Bitmap        
Bitmap bmp = new Bitmap(Server.MapPath(".") + "\\images\\starrating.gif");
if(bmp.Height > bmp.Width)
  //Portrait
else
  //Landscape

Open in new window

0
 
lrbristerAuthor Commented:
I have a "Crop" question coming up.  But thanks for this answer.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now