I was wondering if anyone has some code/useful link explaining on how I could do this.
I would most likely use it this way:
<img src="ShowThumb.aspx?image=http://the_image.jpg" alt="" />
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rather than using an
.aspxfile, use a Generic Handler file (.ashx). This means you only require the 1 file (no markup file), so its a bit neater and a bit quicker. Afterall, you’re not generating a web form, so an.aspxfile isn’t what you’re after.You can make use of
System.Drawing.Graphics.DrawImage()to produce a thumbnail.Something as simple as this will work:
Where
width&heightareintegervalues, andImageURLis a local URI stringI wouldn’t resize your image using width/height attributes in HTML/CSS. This means you are sending the full size image to the client wasting everyones bandwidth and time! Furthermore, when HTML resizes it, it usually does a shoddy distorted job of it.
On a side note, I used to generate on-the-fly thumbnails like this, but decided that the performance was compromised as you are resizing the image everytime a HTTP request is made.
Therefore, whenever the main image was uploaded, I saved the thumbnail to a physical location, and called that in my HTML.