Solved

Resize image as per the availability - Asp.net 2008

Posted on 2010-09-02
3
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
 

Author Closing Comment

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

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 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