The TIFF (Tag Image File Format) is widely used in publishing, graphic design, and photography because of its ability to store high-quality raster graphics. Unlike JPEG or PNG, a TIFF file can hold multiple images or frames within a single file. These multi-frame TIFF images are often used in medical imaging, scanned documents, and layered designs.

Image Processing API

Aspose.Imaging Cloud SDK for .NET is an amazing API based on REST architecture, offering the capabilities to manipulate and process images online. It offers simple and easy approach for extracting tiff frame from multi-frame TIFF image within C# .NET code snippet. The SDK is available for download from NuGet and GitHub. Now, install the REST API to begin manipulating TIFF and other image formats.

Install-Package Aspose.Imaging-Cloud

Get your Client ID and Client Secret from Aspose Cloud dashboard.

Extract TIFF Frames using C#

This section explains the details on how we can easily extract TIFF frame using C# .NET.

  • Firstly, create an object of ImagingApi while providing ClientID and ClientSecret as arguments.
  • Secondly, create an object of GetImageFrameRequest which takes input TIFF name, frameID, and other parameters as arguments.
  • Now, call GetImageFrame(..) method of ImagingApi where we pass GetImageFrameRequest object as input argument.
  • Finally, save the extracted image.

We can provide any of the values to rotateFlipMethod property.

RotateFlip method (Rotate180FlipNone, Rotate180FlipX, Rotate180FlipXY, Rotate180FlipY, Rotate270FlipNone, Rotate270FlipX, Rotate270FlipXY, Rotate270FlipY, Rotate90FlipNone, Rotate90FlipX, Rotate90FlipXY, Rotate90FlipY, RotateNoneFlipNone, RotateNoneFlipX, RotateNoneFlipXY, RotateNoneFlipY). Default is RotateNoneFlipNone.

Get TIFF Frames using cURL

Alternatively, we can also use cURL commands to perform this operation. You may consider using either of the following API calls to perform this operation.

  1. GET /imaging/{name}/frames/{frameId} - Load image from cloud storage and get image in response.
  2. POST /imaging/frames/{frameId} - Pass TIFF in request body and get resultant image in response.

The first step is to generate JSON Web Token (JWT) based on your ClientID and ClientSecret. Therefore, execute the following command in the terminal to generate the JWT token:

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=XXXXXX-XXXXX-XXX-bff4-f5a14a4b6466&client_secret=XXXXXXXXXXX" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now, execute the following command to extract the 2nd frame from TiffSampleImage.tiff image already uploaded on cloud storage.

curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/TiffSampleImage.tiff/frames/2?saveOtherFrames=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o myresultant.tiff

Conclusion

The ability to extract individual frames from multi-frame TIFF images is valuable when working with scanned multipage documents, layered image files, or medical imaging datasets. With Aspose.Imaging Cloud SDK for .NET, you can automate this process easily, using either REST API calls or C# code.

We recommend you to visit the following links to learn about: