Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2005, 02:18 AM
Authorized User
 
Join Date: Oct 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to richie86
Default Convert an image into tumbnail (ASP.NET C#)

Is that anyone know the code that use to convert an image into tumbnail? so that we can display it without creating our own tumbnail.

Goh Hoang Yuh
- C# Beginner in ASP.NET
 
Old November 3rd, 2005, 06:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try somethimg like this...
Code:
private void GenerateThumb(string sourcepath, string folder, string prefix, int width, 
    bool overwrite, bool deletecurrupt)
{
    double factor;
    System.Drawing.Image thumbnail, fullimage;        

    string file = Path.GetFileName(sourcepath);
    string filethumb = folder + (folder.EndsWith(@"\")? "" : @"\") 
            + prefix + "." + file;
    if(overwrite || (!overwrite && !File.Exists(filethumb)))
    {
        try
        {
            fullimage = System.Drawing.Image.FromFile(sourcepath);

            factor = fullimage.Width/(double)width;
            thumbnail = fullimage.GetThumbnailImage(width, 
                (int)(fullimage.Height/factor), null, IntPtr.Zero);
            thumbnail.Save(filethumb, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
        catch(OutOfMemoryException)
        {
            if(deletecurrupt)
                File.Delete(sourcepath);
        }
    }
}
(tested)

The OutOfMemoryException is included since it is thrown when currupted pictures are read using FromFile. In the above sample the currupted file is deleted.

Hope it helps, Jacob.
 
Old November 7th, 2005, 07:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just found this one and might be interesting for others how run into the thumbnail issues...

http://www.devx.com/dotnet/Article/22079/1954?pf=true

Jacob.

(keywords: thumbnails, resize, resolution, quality)
 
Old March 8th, 2007, 12:37 PM
Authorized User
 
Join Date: Jul 2005
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Is it possible to do resizing using Classic ASP?

Cheers -

george






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert html to pdf file by using asp.net in c# dey.susanta.kolkata ASP.NET 2.0 Professional 4 September 19th, 2016 07:20 AM
convert bytes[] into base64binary in asp.net bharat_agarwal XSLT 1 June 20th, 2006 02:04 AM
Convert ASP to ASP. Net jourys ASP.NET 1.0 and 1.1 Basics 3 February 22nd, 2006 08:11 AM
Convert ASP web application to ASP.NET Steve777 ASP.NET 1.0 and 1.1 Basics 3 June 2nd, 2005 07:26 AM
convert asp function to asp.net debuajm General .NET 0 June 11th, 2004 11:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.