Solved

ASP.NET

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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