Solved

Resize image as per the availability - Asp.net 2008

Posted on 2010-09-02
3
403 Views
Last Modified: 2013-12-25
Dear Experts,

I have one web application which includes Album Gallery.  Whenever i do upload the image in this gallery, if the image is of high resolution, it seems like squeezed. Means it do not fit into the image thumbnail.  I have checked the same thing on orkut, when i upload the high resolution image and when it shows thumbnail preview of it, it fits into that thumbnail very easily and when we enlarge the image by clicking on it, the large picture is displayed.  How to achieve this using asp,net with C#

Please help.

Thanks
0
Comment
Question by:swarajya
3 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 250 total points
ID: 33592838
The dimensions of the thumbnail must be in proportion to the original image. You need to calculate the final length and width of the thumbnail based on the size of the original. In your code, first determine if the image is taller than it is wide or wider than it is tall. Decide in advance what the maximum size of the longest side of the thumbnail will be. Below is code for this calculation.


'longest side of finished thumbnail will be 100 pixels
'set both width and height of the thumbnail to the maximum dimension
'then calculate the other dimension
Integer thumbWidth = 100;
Integer thumbHeight = 100;
if (origWidth > origHeight) {           'original image is wider than it is tall
     thumbHeight = origHeight * 100 / origWidth    
} else {                                'original image is taller than it is wide
     thumbWidth = origWidth * 100 / origHeight                                     
}

Open in new window

0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 33593103
0
 

Author Closing Comment

by:swarajya
ID: 33704304
This solution gave me hint to resolve my issue
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

803 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