---
title: "Save image C#: Save JPG, TIFF, BMP, and PNG in C# | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/save-a-file/imaging-byte-array/"
md_url: "https://www.nutrient.io/guides/dotnet/save-a-file/imaging-byte-array.md"
last_updated: "2026-05-21T17:12:02.215Z"
description: "Explore how to save images in various formats using .NET, including bitmap, vector, byte array, FTP, and remote URL methods for efficient file handling."
---

# Save images in C#

### Overview

[Overview](https://www.nutrient.io/guides/dotnet/save-a-file/imaging.md)

### To Bitmap

[To Bitmap](https://www.nutrient.io/guides/dotnet/save-a-file/imaging-bitmap.md)

### To Vector

[To Vector](https://www.nutrient.io/guides/dotnet/save-a-file/imaging-vector.md)

### To Byte Array

[To Byte Array](https://www.nutrient.io/guides/dotnet/save-a-file/imaging-byte-array.md)

### To FTP

[To FTP](https://www.nutrient.io/guides/dotnet/save-a-file/imaging-ftp.md)

### To Remote URL

[To Remote URL](https://www.nutrient.io/guides/dotnet/save-a-file/imaging-remote-url.md)

To save a GdPicture image to a byte array, use the [`SaveAsByteArray` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsByteArray.html) of the [`GdPictureImaging` class](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging.html).

`SaveAsByteArray` parameters:

- `imageID` — The GdPicture image identifier.

- `Data` (by reference) — Byte array that receives encoded image data.

- `Length` (by reference) — Number of valid bytes written to `Data`.

- `ImageFormat` — Output format as a member of the [`DocumentFormat` enumeration](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.DocumentFormat.html).

- `EncoderParameter` — Encoding/compression parameter depending on output format.

`SaveAsByteArray` returns a `GdPictureStatus`, which should be checked.

Typical `EncoderParameter` values:

- **JPEG** — Quality `1` to `100`

- **PNG** — Compression level `0` to `9`

- **TIFF** — Values from [`TiffCompression` enumeration](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.TiffCompression.html)

- **JPEG2000** — Compression rate `1` to `512`

- **WebP** — Quality `1` to `100`

- **Other formats** — Usually `0`

When you no longer need an image resource, release it with the [`ReleaseGdPictureImage` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html).

The following example saves a previously loaded JPG image to a byte array:

### C#

```csharp

using GdPicture14;
using System;
using System.IO;

using GdPictureImaging gdPictureImaging = new GdPictureImaging();

int imageID = gdPictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
if (imageID == 0)
{
    Console.WriteLine($"CreateGdPictureImageFromFile failed: {gdPictureImaging.GetStat()}");
    return;
}

byte[] data = Array.Empty<byte>();
int length = 0;

GdPictureStatus status = gdPictureImaging.SaveAsByteArray(
    imageID,
    ref data,
    ref length,
    DocumentFormat.DocumentFormatPNG,
    9);

if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SaveAsByteArray failed: {status}");
    gdPictureImaging.ReleaseGdPictureImage(imageID);
    return;
}

File.WriteAllBytes(@"C:\temp\output.png", data.AsSpan(0, length).ToArray());
gdPictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Imports GdPicture14
Imports System.IO

Using gdPictureImaging As New GdPictureImaging()
    Dim imageID As Integer = gdPictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    If imageID = 0 Then
        Console.WriteLine($"CreateGdPictureImageFromFile failed: {gdPictureImaging.GetStat()}")
        Return
    End If

    Dim data As Byte() = {}
    Dim length As Integer = 0

    Dim status As GdPictureStatus = gdPictureImaging.SaveAsByteArray(
        imageID,
        data,
        length,
        DocumentFormat.DocumentFormatPNG,
        9)

    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SaveAsByteArray failed: {status}")
        gdPictureImaging.ReleaseGdPictureImage(imageID)
        Return
    End If

    Dim outputData(length - 1) As Byte
    Array.Copy(data, outputData, length)
    File.WriteAllBytes("C:\temp\output.png", outputData)

    gdPictureImaging.ReleaseGdPictureImage(imageID)
End Using

```
---

## Related pages

- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-pdf.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-jpg.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-bitmap.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-tiff.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-vector.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-ftp.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-xmp.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-remote-url.md)
- [Save images and PDF files in C#](/guides/dotnet/save-a-file.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-incremental.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-local-storage.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-stream.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-incremental-to-stream.md)

