This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/load-a-file/imaging/from-byte-array-image.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Load an image from byte array in C# .NET | Nutrient .NET SDK
Image

To load an image from a byte array, use the CreateGdPictureImageFromByteArray method of the GdPictureImaging class.

This method returns a non-zero GdPicture image identifier (imageID) on success. If it fails, it returns 0 — use GetStat() to view the failure reason.

Overloads:

  • CreateGdPictureImageFromByteArray(byte[] Data)
  • CreateGdPictureImageFromByteArray(byte[] Data, DocumentFormat ImageFormat)

The optional ImageFormat parameter is a member of the DocumentFormat enumeration.

When you no longer need the image resource, release it with the ReleaseGdPictureImage method.

To load an image from a byte array, use the following code:

using GdPicture14;
using System;
using System.IO;
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Load bytes from an image file.
byte[] byteArray = File.ReadAllBytes(@"C:\temp\source.jpg");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(
byteArray,
DocumentFormat.DocumentFormatJPEG);
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromByteArray failed: {gdpictureImaging.GetStat()}");
return;
}
GdPictureStatus status = gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveAsPNG failed: {status}");
}
gdpictureImaging.ReleaseGdPictureImage(imageID);