Load a TIFF from a remote URL in C#

TIFF

To load a TIFF image from a remote URL, use the CreateGdPictureImageFromHTTP method from the GdPictureImaging class. This method creates a new GdPicture representation of an image and returns a unique non-zero image identifier — imageID — of the newly created GdPicture image. This method requires two different sets of parameters depending on the type of server:

Loading a TIFF image from a public server

When the server you want to get the image from is public, then the CreateGdPictureImageFromHTTP method requires the following parameters:

  • Host — Server host name where the image is located.
  • Path — Image file path on the host server.
  • HTTPPort — Server port number.

Remember to release the image resource once you stop using it. Use the ReleaseGdPictureImage method.

When transferring data to or from remote servers, you can optionally use the SetHttpTransferBufferSize method to specify the maximum package size of the transferred data. By default, the buffer size is 4096.

To load a TIFF image from a public server, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a GdPicture image from a TIFF image on a public server.
int imageID = gdpictureImaging.CreateGdPictureImageFromHTTP("https://pspdfkit.com",
"downloads/load-a-file/source.tif", 443);
// Save to a PNG image.
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);

Loading a TIFF image from a protected server

When the server you want to get the image from is private, then the CreateGdPictureImageFromHTTP method requires the following parameters:

  • Uri — Full path to a TIFF image.
  • Login — Login used to authenticate the connection on the server.
  • Password — Password required to authenticate the connection on the server.

Remember to release the image resource once you stop using it. Use the ReleaseGdPictureImage method.

When transferring data to or from remote servers, you can optionally use the SetHttpTransferBufferSize method to specify the maximum package size of the transferred data. By default, the buffer size is 4096.

To load a TIFF image from a protected server, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a GdPicture image from a TIFF image on a protected server.
int imageID = gdpictureImaging.CreateGdPictureImageFromHTTP("https://pspdfkit.com/downloads/load-a-file/source.tif",
"admin", "password");
// Save to a PNG image.
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);