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

To load an image from a Stream, use the CreateGdPictureImageFromStream method from 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.

Available overloads include:

  • CreateGdPictureImageFromStream(Stream)
  • CreateGdPictureImageFromStream(Stream, DocumentFormat ImageFormat)
  • CreateGdPictureImageFromStream(Stream, DocumentFormat ImageFormat, bool DirectAccess)

Notes:

  • The stream must support seeking.
  • If DirectAccess is true, only properties/metadata/thumbnail are loaded; pixel operations will fail.
  • For multipage formats (for example TIFF/GIF), keep the stream open until the image is released.

Remember to release image resources with the ReleaseGdPictureImage method.

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

using GdPicture14;
using System;
using System.IO;
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a stream object from an image file.
using Stream streamImage = new FileStream(@"C:\temp\source.jpg", FileMode.Open, FileAccess.Read);
// Create a GdPicture image from the stream object.
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(
streamImage,
DocumentFormat.DocumentFormatJPEG);
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromStream 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);