To Remote URL

To save a previously loaded GdPicture image to a remote URL, use the SaveToHTTP method of the GdPictureImaging class.

SaveToHTTP uploads the image using HTTP PUT.

Main parameters:

  • imageID — The GdPicture image identifier.
  • ImageFormat — Output format as a member of the DocumentFormat enumeration.
  • EncoderParameter — Encoding/compression parameter (depends on format).
  • Address — Destination URL.
  • Login/Password (optional) — Credentials for authenticated endpoints.

SaveToHTTP returns a GdPictureStatus, which should be checked.

In some environments, network/DNS failures for SaveToHTTP(...) may surface as runtime transfer exceptions (for example, host resolution errors) instead of only a non-OK GdPictureStatus. We recommend wrapping remote upload calls in try/catch in addition to checking GdPictureStatus.

Typical EncoderParameter values:

  • JPEG — Quality 1 to 100
  • PNG — Compression level 0 to 9
  • TIFF — Values from TiffCompression enumeration
  • 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.

When transferring data to or from remote servers, you can optionally use the SetHttpTransferBufferSize method to specify transfer buffer size.

The following example saves a previously loaded JPG image to a remote URL:

using GdPicture14;
using System;
using GdPictureImaging gdPictureImaging = new GdPictureImaging();
int imageID = gdPictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromFile failed: {gdPictureImaging.GetStat()}");
return;
}
gdPictureImaging.SetHttpTransferBufferSize(2048);
GdPictureStatus status = gdPictureImaging.SaveToHTTP(
imageID,
DocumentFormat.DocumentFormatJPEG,
75,
"https://pspdfkit.com/uploads/source.jpg");
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveToHTTP failed: {status}");
}
gdPictureImaging.ReleaseGdPictureImage(imageID);