<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx</link><description>When I was working the update for my Ajax demo , I needed to create thumb nail from a director of photos. There are tons of tools out there to do this, but I thought I'd share the very simple code I used. It takes all the jpgs in the root path and creates</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8717980</link><pubDate>Thu, 10 Jul 2008 21:17:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8717980</guid><dc:creator>Richard</dc:creator><description>&lt;p&gt;Due to a &amp;quot;feature&amp;quot; of GDI+, calling Image.FromFile will keep the file locked until your process exits. If you're creating thumbnails from a long-running process (ASP.NET, Windows Service, etc.), you may want to use Image.FromStream instead:&lt;/p&gt;
&lt;p&gt;using (Stream fs = File.OpenRead(s))&lt;/p&gt;
&lt;p&gt;using (Image i = Image.FromStream(fs))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;...&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;NB: You can't dispose of the stream until you've finished with the image:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://support.microsoft.com/kb/814675"&gt;http://support.microsoft.com/kb/814675&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8718482</link><pubDate>Thu, 10 Jul 2008 23:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8718482</guid><dc:creator>Omer van Kloeten</dc:creator><description>&lt;p&gt;AFAIK, running GDI+ in an ASP.NET process is considered harmful and is unsupported by Microsoft.&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8718708</link><pubDate>Fri, 11 Jul 2008 00:23:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8718708</guid><dc:creator>Otto</dc:creator><description>&lt;p&gt;If you use this on GIF or PNG images with transparency, what happens?&lt;/p&gt;
</description></item><item><title>Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8718994</link><pubDate>Fri, 11 Jul 2008 01:43:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8718994</guid><dc:creator>拝啓、サカモトと申します。</dc:creator><description>&lt;p&gt;Very Simple .NET Thumbnail Creation Code&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8720213</link><pubDate>Fri, 11 Jul 2008 08:27:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8720213</guid><dc:creator>John S.</dc:creator><description>&lt;p&gt;GetThumbnailImage has a few issues. I highly recommend the method described here: &lt;a rel="nofollow" target="_new" href="http://www.glennjones.net/Post/799/Highqualitydynamicallyresizedimageswithnet.htm"&gt;http://www.glennjones.net/Post/799/Highqualitydynamicallyresizedimageswithnet.htm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In my opinion, the .NET image handling libraries are lacking some simple abstractions for consistent handling of jpg, gif (both transparent and not) and png resizing. It is way more complicated than it should be.&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8720732</link><pubDate>Fri, 11 Jul 2008 12:16:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8720732</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Also, be careful because if you don't specify an image encodig, it will just create a png. You might not notice, because when you open the file (test.jpg) it will display most of the time, but it could be an actual png file, and in some programs it might not open.&lt;/p&gt;
&lt;p&gt;Seriously, posting these &amp;quot;this is simple, do it in 3 lines of code&amp;quot; articles are a bad idea hmmkay. Programming is not simple, and image processing is not simple either.&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8721089</link><pubDate>Fri, 11 Jul 2008 15:16:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8721089</guid><dc:creator>Eric</dc:creator><description>&lt;p&gt;And why not use Directory.Delete(path, true) for recursive deletion of everything in the directory instead of coding a subroutine to do that?&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8721460</link><pubDate>Fri, 11 Jul 2008 18:12:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8721460</guid><dc:creator>mihailik</dc:creator><description>&lt;p&gt;I can't believe you've forgotten to call Dispose!&lt;/p&gt;
</description></item><item><title>re: Very Simple .NET Thumbnail Creation Code</title><link>http://blogs.msdn.com/brada/archive/2008/07/10/very-simple-net-thumbnail-creation-code.aspx#8845481</link><pubDate>Sun, 10 Aug 2008 04:25:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8845481</guid><dc:creator>Nathanael Jones</dc:creator><description>&lt;p&gt;You can generate resized thumbnail versions on-the-fly with this module:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://nathanaeljones.com/products/asp-net-image-resizer/"&gt;http://nathanaeljones.com/products/asp-net-image-resizer/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It's very stable, and includes disk caching for scalability.&lt;/p&gt;
&lt;p&gt;You would just add ?thumbnail=jpg&amp;amp;maxwidth=160&amp;amp;maxheight=120 to the image path.&lt;/p&gt;
</description></item></channel></rss>