Solved

Resize image as per the availability - Asp.net 2008

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

762 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

20 Experts available now in Live!

Get 1:1 Help Now