In this tutorial, you will configure a C# or VB.NET project for a console application and use ImageGear .NET capabilities. You will also learn how to load an image, then resize and convert it to a new format.
The following tutorial refers specifically to 64-bit installations; for 32-bit installations:
- Your project should already be set to compile to target Debug and x86, and you should have the directory: $YOURLOCALPROJ\bin\x86\Debug\.
- Throughout these instructions, replace x64 with x86.
- The 32-bit ImageGear binaries are found in $INSTALLDIR\ImageGear .NET v24\Bin\
Using the desired version of Visual Studio (2010 or later):
- Create a new "Console Application" project, using C# or VB.NET and name the project: IG_Tutorial_Console.
- If you installed ImageGear .NET 64-bit, using the Configuration Manager, create a new project platform (if you don't have one already) for x64. Make sure your project is set to compile targeting Debug and x64. Make sure you now have $YOURLOCALPROJ\bin\x64\Debug\, and if is not there, create it.
- Add references and required resources into your projects in one of the following ways:
- Recommended: use our NuGet Packages. For this project, you need the following package:
Accusoft.ImageGear.Core.nupkg (https://www.nuget.org/packages/Accusoft.ImageGear.Core/)
- Manually:
- Copy all files (and folders) inside $INSTALLDIR\ImageGear .NET v24 64-bit\Bin\ to your local output bin directory in your project (i.e., $YOURLOCALPROJ\bin\x64\Debug\ ).
- Add the following references to your project from $YOURLOCALPROJ\bin\x64\Debug\:
- ImageGear24.Core.dll
- ImageGear24.Evaluation.dll
- ImageGear24.Formats.Common.dll
Your output target directory should be set to $YOURLOCALPROJ\bin\x64\Debug\
- At this point your project is ready for some code. The following code can be used to load an image, resize it to a 150 x 150 dimension, and convert it to another format specified by the user. In the next step, we will go over some areas of this sample code in more detail.
- If you are using a Deployment (Runtime) licensing, add the license initialization code. This is not necessary if you are using an Evaluation or Development (Toolkit) license. Please add the ImGearEvaluationManager.Initialize() call if you are evaluating the product.
- We load the image using:
- We resize the image by defining the width, the height, and the interpolation approach as follows:
- Finally, we save the image based on the savingFormat specified: