Note: This blog has been moved to

Sunday, December 03, 2006

Creating Thumbnails in a Single line of Code

I've posted this before, but it was a bit too convulated(just showin my age:D). So, here's another try, a single logical line statement that will generate Thumbnail of any image:

Dim I as Image

I = Image.FromFile("F:\Dash.jpg").GetThumbnailImage(tWidth, tHeight, Nothing, IntPtr.Zero)

That will give you an Image object with dimensions tWidth and tHeight. The Nothing and IntPtr.Zero are there for reasons which I have no idea about. You can do anything with it, such as save it to another file:


This will save the thumbnail as "TNail.png" in the PNG Format. The .NET Framework supports almost all of the popular formats(GIF, PNG, BMP, JPEG, etc) So, hack away!

And, if you wanna do this in ASP.NET web pages, here's a pretty good article on how to.


Post a Comment

<< Home