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

x
?
Solved

Resize image as per the availability - Asp.net 2008

Posted on 2010-09-02
3
Medium Priority
?
409 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 750 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
 

Author Closing Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

824 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