Solved

ASP.NET

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

22 Experts available now in Live!

Get 1:1 Help Now