Nic was hanging out with Nick (a combination that's just asking for trouble if you ask me) a couple of weeks ago near my desk, and Nic was bemoaning the lack of a resizing utility. This triggered something in the back of my mind and lo! I found a post by Rick Strahl on (almost) this very thing. I tweaked the code a little to turn it into a console app from a web app and built it.
I added a shortcut to the exe both on my desktop and in my SendTo folder so now I can right-click on an image or images and send it to the resizer and it will do its magic.
(508k) turns into this (23k):
Here's the code - most of it pinched directly from Rick remember. Note that in its current form, it makes the maximum dimension of the thumbnail 120px. You can change that at the top. I've also attached a zipped version of the solution to this post. Of course, this is provided as-is with no guarantees of stability, suitability or any other -ability. Use at your own risk, contents may be hot, don't run with scissors etc.
You could add some nice bits like:
Anyway, enough already. Go play!
Default = 120,
Small = 120,
Medium = 240,
Large = 480,
static void Main(string args)
foreach (string Image in args)
// string Image = args;
if (Image == null)
int Size = (int)ImageSize.Default;
//if (args.Length > 1)
// string sSize = args;
// if (sSize != null)
// Size = Int32.Parse(sSize);
string Path = Image;
Bitmap bmp = CreateThumbnail(Path, Size, Size);
if (bmp == null)
string OutputFilename = null;
FileInfo OutputFile = new FileInfo(Path);
OutputFilename = OutputFile.DirectoryName + "\\" + OutputFile.Name.Remove(OutputFile.Name.Length - (OutputFile.Extension.Length)) + "[" + Size.ToString().Trim() + "]" + OutputFile.Extension;
if (OutputFilename != null)
catch (Exception ex)
private static void ErrorResult()
//throw new Exception("The method or operation is not implemented.");
/// Creates a resized bitmap from an existing image on disk.
/// Call Dispose on the returned Bitmap object
/// Taken from Rick Strahl's code at
/// Bitmap or null
public static Bitmap CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)
Bitmap bmpOut = null;
Bitmap loBMP = new Bitmap(lcFilename);
ImageFormat loFormat = loBMP.RawFormat;
int lnNewWidth = 0;
int lnNewHeight = 0;
//*** If the image is smaller than a thumbnail just return it
if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
if (loBMP.Width > loBMP.Height)
lnRatio = (decimal)lnWidth / loBMP.Width;
lnNewWidth = lnWidth;
decimal lnTemp = loBMP.Height * lnRatio;
lnNewHeight = (int)lnTemp;
lnRatio = (decimal)lnHeight / loBMP.Height;
lnNewHeight = lnHeight;
decimal lnTemp = loBMP.Width * lnRatio;
lnNewWidth = (int)lnTemp;
// System.Drawing.Image imgOut =
// *** This code creates cleaner (though bigger) thumbnails and properly
// *** and handles GIF files better by generating a white background for
// *** transparent images (as opposed to black)
bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
I'm doing a (long overdue) rebuild of my Toshiba M200 to get rid of any Beta1/Beta2/CTP/RC gremlins.
Here's the process I use, as well as the checklist of things to install (in no particular order)
0. Backup the data that live on my HDD and are not replicated elsewhere. I use folder redirection for my My Documents folder, so all that lives on a server somewhere that's backed up, volume shadow copied and generally made available offline. I use the Files and Settings Transfer Wizard and also do an xCopy of my working folders to an external HD
1. Install the base OS from the media or the network (in this case it's from my VISTA CD burnt from the internal share)
2. Install Patches, SPs and Hotfixes (Microsoft Update is your friend)
3. Install Anti-virus
4. Join the Domain
5. Install all the Apps
I've just spent 4 days of last week on Readify's excellent Industrial Strength .NET Course, lead by the incomporable Mitch Denny. Things really started to hot up on the last day when we discussed the merits of natural vs artificial primary keys in tables (try as we might, we couldn't get Mitch to see the light <g>). Mitch also proposed the ditching entirely of SQL to be replace with an object-oriented construct something like:
objectDataSet Customers = new objectDataSet("select * from Customers");objectDataSet ImportedCustomers = new objectDataSet("Select * from ImportTable");objectDataSet MissingCustomers = ImportedCustomers - Customers;
objectDataSet Customers = new objectDataSet("select * from Customers");
objectDataSet ImportedCustomers = new objectDataSet("Select * from ImportTable");objectDataSet MissingCustomers = ImportedCustomers - Customers;
An interesting overloading concept, but it leaves a lot of questions unanswered.
I've been talking about this for a while, and I've finally uploaded a COM wrapper around the MapPoint Web Service and a sample VFP form that shows the Find and Render services. You can grab them both from Darren's most excellent ProjectDistributor site.
To use them, you'll need a MapPoint WS eval account, or, if you're an MSDN subscriber Sign up for a MapPoint Web Service Developer Account. If you want to explore the SDK, you can get it here.
Celebrate the new Financial Year with another great set of labs. ASP.NET Virtual Labs (from the MSDN Suite of Virtual Labs)
With ASP.NET you create richer Web applications with fewer lines of code. These virtual labs teach you about the innovations that debuted with ASP.NET 1.x and introduces you to the major improvements introduced with ASP.NET 2.0. These include dozens of new controls, new Membership and Profile application services and support for creating multiple pages based on a common template using Master Pages. Begin exploring Web development with ASP.NET and Visual Web Developer 2005 Express Edition today.
What's new in ASP.NET 2.0Virtual Lab Express is the fastest and easiest way to test drive Microsoft products and the Virtual Lab environment. These are 20-minute hands-on overviews of some of your favorite Microsoft products and developer tools. Try them out online now - no need to download full trial versions or dedicate test machines.
You get a downloadable manual and a 90-minute block of time for each module. You can sign up for additional 90-minute blocks at any time.
As David Hayden notes in this post, the Patterns and Practices team has a series of webcasts about the recently released Enterprise Library. Some have already happened, some are still to come, but all are or will be available as recordings.
Note: All Webcast times are Pacific Standard Time (GMT-8:00)To get to Australian Eastern Daylight Time (GMT+11), subtract 5 hours and add a day. After that, you're on your own. I have translated the dates into DD/MM/YYYY from the wierd format the yanks use.
Enterprise Library Overview
Enterprise Library is the next generation of the patterns & practices Application Blocks. This guidance is designed to assist developers with common enterprise development challenges and will deliver the most widely used blocks into a single integrated package. Our vision is to build a broad community of customers and partners using, sharing and extending their own Application Blocks that are consistent with and integrate into the patterns & practices Enterprise Library.
Enterprise Library Configuration Application Block
Configuration data is a constant challenge for application development. The way in which your application handles configuration data dramatically impacts its manageability. In this webcast we will discuss the requirements for building a great configuration system and how you can leverage the configuration application block to meet these requirements.
Enterprise Library Data Access Application BlockDiscover how you can implement the recommended data access architecture using Enterprise Library to quickly build a robust and secure data access layer which supports connectivity to SQL Server, Oracle and DB2.
Enterprise Library Caching Application Block
Properly designed caching can make your system more robust and increase performance dramatically, poorly designed caching adds unnecessary overhead and provides little benefit. Learn how you can make use of the new caching application block to help lessen the demand on your back-end systems while increasing throughput.
Enterprise Library Logging & Instrumentation Application Block
Properly instrumented applications are a dream to manage, they tell what is happening and when things are going wrong point you to the source of the problem quickly increasing your mean time to recovery resulting in increased system availability. In this webcast you will learn how to use the Enterprise Library logging and instrumentation block to consistently and easily build an application that tells you where it hurts.
Enterprise Library Exception Handling Application Block
Exceptions happen...the question is what you will do to handle them. Poorly written applications behave unpredictably when exceptions occur and often this bad behavior results in crashes or security holes. Learn how you can create exception policies that can be consistently and quickly applied in your application to insure predictability even when things go wrong.
Enterprise Library Cryptography Application Block
So you have a secret...what are you going to do with that credit card number, connection string or password? Stuff in a secret place and hope that no one ever finds it? Of course not, you want to encrypt it. But how? With the Enterprise Library cryptography block you can quickly encrypt and decrypt these secrets allowing you to secure them and sleep better at night.
Enterprise Library Security Application Block
Every enterprise needs security and within most large enterprises there are many different security systems. Discover how Enterprise Library’s security block can help you to put a consistent API in front of many different back end implementations allowing you to use these security systems without having to become an expert in them.
Enterprise Library - Building your own application block
So you love application blocks? You want to create your own and share it with your colleagues, your enterprise...the world? Great! We want to help you. In this session we will walk through a simple application block to consider how you can build a block that integrates with the rest of Enterprise Library.
Enterprise Library Applied
You stand at your manager’s door working up the courage to walk in and tell them that you want to use Enterprise Library in your next project. There are so many questions about support, licensing, maintenance and futures...good thing you listened to this webcast to understand what it means for an enterprise to adopt this library. As you listen to real examples from enterprises like yours to understand how they are managing the risks and opportunities associated with Enterprise Library
I had a great time over the last couple of days hanging out with Christen Boyd and some of the other folk from the VSTO team here in Seattle. This culminated yesterday with a webcast of the session I’ll be doing here next week and then again at TechEd in Sydney. As promised, here are my slides from that session.
I’ve added one blog to the list of resources. I had the pleasure of meeting Kris Makey yesterday and his VSTO deployment blog is great. Subscribed.
Here is a summary of the VSTO resources I list at the end of the deck:
I've been meaning to blog about this for ages, but better late than never I guess.
One of the questions to which I get the most positive response when showing the great new features in VS2005 (or even VS2003 for that matter) is "Who here would laike to be able to write .NET applications that live inside Word or Excel?". Especially in financial institutions, law firms and beauracracies (but in plenty of other places as well), there are light bulbs going off over the developers' heads as they realise that their users don't have to ever leave thier beloved Office app to get the functionality they need -- no mater what that functionality is!
Over on the VSTO 2.0 blog, Kathleen McGrath has been posting links to video tutorials showing how to do a bunch of great things in VSTO 2.0. Here's what she's posted so far:
Dunno if that's the lot or not, but either way, these are well worth a look.
Internally, especially when I'm wearing my cool VFP 9.0 shirt, this has to be one of the most common questions I hear. Of course, the answer is YES! David Anderson has written an opinion piece on DevX entitled Visual FoxPro 9.0: Still Here, Still Relevant. The article has an interesting history of Visual FoxPro and a discussion about why it will never be a .NET CLR language.
If you want to get more information about the history of VFP, check out www.FoxProHistory.org.
There are a number of VFP links in the links section of this blog.
It's 8am and I'm sitting in the inaugural meeting of the Canberra VSTS User Group. The turn-out is amazing. Over 40 professionals are crammed into the room in the Canberra MS office. This is a sensational turn out. Kudos to Grant, Sean and Mitch.
Grant kicked off with news, tips and tool of the month (he chose Brian Harry's TFSServerManager Power Toy).
Andrew Lyons talked about his experience migrating a 100 developer government department (DEWR) from a VSS environment to TFS (for source control mainly). His final word(s):
Planning is Key
Particularly with initial deployment
Disaster recovery plan
Practice Makes Perfect
Non-trivial migrations need trial runs
A development TFS server is invaluable
Planning is Key
Practice Makes Perfect
Next, Sean Ferguson talked about branching and merging in the ATO development environment. A couple of things that stood out for me were a reference to Buck Hodges' great post from 2004 on branching models and the usefulness of the TFS Power Tools (see also Brian's post).
Finally, Stu and Rick from AFP talked about their experience with branching there. One of their main points was that there needs to be a lot of work done to introduce the TFS culture to the dev team (especially as many of the current devs have strongly entrenched opinions about the current process and are resistant to any sort of change).
All-in-all a great first meeting and I'm looking forward to the next one on Feb 28!