Solved

ASP.NET

Posted on 2008-06-13
4
144 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 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now