Solved

Resize image as per the availability - Asp.net 2008

Posted on 2010-09-02
3
405 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

Technology Partners: 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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

680 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