A windows command line application to resize images in a directory

by Kevin Bosch 24. August 2010 20:16

I came across a need to resize a whole bunch of images. So I decided to write a little console application in .NET to do the work for me. With 100’s of images to resize it was worth the effort in creating a little application to do the job for me. CA.Console.ResizeImage.exe is what I came up with the source code is listed in this post

CA.Console.ResizeImage.exe is a command line windows utility that resizes the following supported images "jpeg,gif,bmp,png" in a given directory to a maximum size keeping the aspect ratio. It is possible to configure the source, destination and maximum size of the images via config file or command line switches it also has some default options for click and go solution. You can download the ziped binary and config file CA.Console.ResizeImage.exe.zip (4.69 kb).

In the simplest case, you can just copy CA.Console.ResizeImage.exe into the directory of your images and double click on it. It will then generate new images with the same name into a folder called ResizedImages without any configuration it will resize all images to 500 x 500 adjust height or width accordingly to keep aspect ratio. More...

Tags: ,

.NET Development | DataTable

Implicit operator

by Kevin Bosch 26. January 2009 08:54

I find from experience on of the least used features in C# is the Implicit operator. The implicit keyword is used to declare an implicit user-defined type conversion operator. This allows the implicit conversion without being specified by explicit casts in the source code. The best way to show this is by way of an example in returning meaningful Boolean results.

For example returning the result from an authentication function often involves checking the result to see it was successful or not. In the case it was not successful giving an indication as to why it was not successful. E.g. expired, locked out, incorrect password, unknown account etc.  

The code is simple for this is simple:

//Source code from the Code Associate C# code library, Full documentation and latest updates can be found
//@ http://www.codeassociate.com/caapi/
using System;
using System.Collections.Generic;
using System.Text;

namespace CA.Common
{

    public struct BoolResultMessage
    {
        public bool Success;

        public string Message;

        public static implicit operator bool(BoolResultMessage result)
        {
            // this the majic that makes the struct work the the if statement.. ie if(BoolResultMessage) ... 
            return result.Success;
        }
    }
}

 

You can find examples on how to use this class at http://www.codeassociate.com/caapi/html/T_CA_Common_BoolResultMessage.htm

Tags:

.NET Development | C#

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Code Associate