Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET

Posted on 2008-06-13
4
Medium Priority
?
153 Views
Last Modified: 2013-11-26
Anyone have a tool that I can use to set aspect ratios on images for uplaods?  I'm getting stretched vertical mimages.
0
Comment
Question by:lrbrister
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21780478
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
 

Author Comment

by:lrbrister
ID: 21780587
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
 
LVL 21

Accepted Solution

by:
naspinski earned 2000 total points
ID: 21780715
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
 

Author Closing Comment

by:lrbrister
ID: 31466980
I have a "Crop" question coming up.  But thanks for this answer.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question