YuviSense: Codin Kid

Yuvi, a 17 year old wannabe geek from India.
  • rss
  • Blog
  • Photography
  • Indians on Twitter
  • About Me
  • Contact

[Tech]Creating thumbnails of an Image in just a single Line…

April 15, 2006 | 10:22 pm
Well, Thumbnails were all the rage during the dot-com era, during which I had no idea of the Internet. And, they were all useful in the good ol’ [though for me non-existent] Dialup Days. Though they’re of less importance now due to the explosion of Broadband, thumbnails are still useful. So, here’s a simple one line of code that would convert any Image of practically any widely used Format into a Thumbnail of a given size into many widely used Image Formats.

System.Drawing.Image.FromFile _
("c:\MyPicture.png").GetThumbnailImage _
(150, 150, Nothing, System.IntPtr.Zero).Save _
("C:Thumbnail.gif", System.Drawing.Imaging.ImageFormat.Gif)

OK, that’s not one Physical Line, but it is one Logical Line, so that 1 Line Claim still holds:D OK, let’s see what we’re doing here…

First up, we are using the FromFile static Method of the System.Drawing.Image class to load an Image from disk and return an Image Object, with which we immediately call GetThumbnailImage, with the width and height of the Thumbnail, along with a dubious Nothing [Null for C#ers] and a Zero Pointer. I donno why they are there, but the docs said that though they weren’t used, they had to be there. Donno why. Poor Framework Design:P

Anyway, the GetThumbnailImage call returns yet another Image object, on which we call the Save Method with the File Name and the Image Format of the Thumbnail file. Intristically, .NET supports 10 Image Formats. List of them found here

BTW, I made the Code a bit Unreadable using line continuation, inorder for that 1 line Title:D Sorry about that.

And, Where are the comments ?

Categories
Tech
Comments rss
Comments rss
Trackback
Trackback

« CSC…. Why am I targeted ? »

6 responses

You always come up with some interesting bits of info

Aswin Anand T.H. | April 16, 2006 | 2:06 am

You always come up with some interesting bits of info :D…very nice!

Dude, ur blog doesnt render properly in IE6

Aswin Anand T.H. | April 16, 2006 | 2:53 pm

Dude, ur blog doesnt render properly in IE6

Yea I know. Ramesh told me already about it. Problem

Yuvi Panda | April 16, 2006 | 2:55 pm

Yea I know. Ramesh told me already about it. Problem is, I don’t have IE6 to test it on! I was planning to use a VM to test it on, but since Dad is delaying my hardware upgrade, I’ve to wait some time. Sorry IE6 People…..

Very nice! I found a place where you can make

Anonymous | April 21, 2006 | 3:31 pm

Very nice! I found a place where you can
make some nice extra cash secret shopping. Just go to the site below
and put in your zip to see what’s available in your area.
I made over $900 last month having fun!
make extra money

[...] I’ve posted this before, but it was a bit

YuviSense: Geek under Development » Creating Thumbnails in a Single line of Code | December 3, 2006 | 10:07 am

[…] 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: […]

[...] I’ve posted this before, but it was a bit

Creating Thumbnails in a Single line of Code » YuviSense: Geek under Development | December 23, 2006 | 3:11 am

[…] 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: […]

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Contact Me

Email: yuvipanda@gmail.com
IM: yuvipanda@msn.com
GTalk: yuvipanda

My Photos


View my Flickr Page

My Badge


IndiBlogger - Where Indian Blogs Meet

Archives

  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox