# Getting Started with CVB.Net

**URL:** <https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246>\
**Category:** .Net API\
**Tags:** csharp, tutorial\
**Created:** [September 9, 2019, 10:00pm UTC](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246 "2019-09-09T22:00:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [September 9, 2019, 10:37pm UTC](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246/2 "2019-09-09T22:37:23Z")

</div>

# Loading and Saving Images (Console)

Let’s start very simple: we want a _Console_ app that takes two arguments:

1. Image input path
2. Image output path

The app loads the image given as the first argument and saves to the path in the second argument:

1. Add namespace (we need the _Stemmer.Cvb.dll_ for this):

2. Load the input image via `Image.FromFile` factory method:

3. Save the image:

:cvb: determines the file format based on the file’s extension (.bmp, .jpg, .png,…).

> **The full app with (simple) error handling.**
>
> ```auto
> using Stemmer.Cvb;
> using System;
> using System.IO;
> 
> namespace CvbPlayground
> {
> class Program
> {
> static void Main(string[] args)
> {
> if (args.Length != 2)
> {
> PrintHelp();
> return;
> }
> 
> try
> {
> using (var inputImage = Image.FromFile(args[0]))
> {
> inputImage.Save(args[1]);
> 
> Console.WriteLine("Convert");
> Console.WriteLine(" " + Path.GetFullPath(args[0]));
> Console.WriteLine("->");
> Console.WriteLine(" " + Path.GetFullPath(args[1]));
> }
> }
> catch (IOException ex)
> {
> Console.WriteLine(ex);
> }
> }
> 
> private static void PrintHelp()
> {
> Console.WriteLine("Usage: " + AppName + " <input> <output>");
> Console.WriteLine();
> Console.WriteLine("<input> Path to input file to convert.");
> Console.WriteLine("<output> Path to output file to convert.");
> }
> 
> private static string AppName
> {
> get
> {
> return Path.GetFileNameWithoutExtension(typeof(Program).Assembly.Location);
> }
> }
> }
> }
> 
> ```
> 
> If you read so far 👏, you get a little bonus: perhaps you have seen the `using (var inputImage`… block. :cvb: `Image`s are `IDisposable` types. That means that you can free their resources (memory in this case) immediatly via `image.Dispose()`. A `using` block does that _always_ when the program exits its scope. Even if exceptions occur. So we use the _image_ only as long as we actually need it.

---

_[View the full topic](https://forum.commonvisionblox.com/t/getting-started-with-cvb-net/246)._
