Append TIFF Images

Combine TIFF Images using Java Cloud SDK

The TIFF files store much more image data than their JPEG counterparts. This makes them a favorite with photographers due to their stunning image quality. Predominantly lossless compression means TIFF files retain the original image’s detail and color depth — perfect for high-quality professional photos. Their impressive detail means TIFFs are ideal for high-resolution scans, such as backing up your handmade artwork and personal documents. When working in distributed teams, we continue to generate numerous TIFF images and may stumble upon a requirement to combine TIFF images. So owing to this fact, we are going to learn the details on How to Merge TIFF Files using Java Cloud SDK.

Merge TIFF API

We have developed Aspose.Imaging Cloud SDK for Java that supports the feature to edit, manipulate and transform raster, metafiles, photoshop and other Supported Formats to variety of outputs. It also enables us to concatenate TIFF images within Java application. So the first step in utilizing its capabilities is to add its reference in java project by including following information in pom.xml (maven build type project).

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-imaging-cloud</artifactId>
        <version>22.4</version>
    </dependency>
</dependencies>

Once the SDK references have been added, please obtain your client credentials details from Cloud Dashboard and if you do not have an account over Aspose Cloud Dashboard, please create a free account through valid email address. Now login using newly created account and lookup/create Client ID and Client Secret at Aspose Cloud Dashboard.

Combine TIFF Images in Java

Now we are going to explore the details on how we can append tif files using Java code snippet.

  • Firstly, create an object of ImagingApi based on personalized client credentials
  • Secondly, read the content of first TIFF image using readAllBytes(…) method and pass to byte[] array
  • Thirdly, create an instance of UploadFileRequest class where we specify the name of TIFF over Cloud storage
  • Now upload first TIFF image to cloud storage using uploadFile(…) method
  • Repeat same steps to read and upload second TIFF image to Cloud storage
  • Now we need to create an object of AppendTiffRequest where we specify the names of TIFF images to be merged
  • Initiate the TIFF merge operation using appendTiff(…) method of ImagingAPI
  • Since the resultant file is storage in CLoud storage, so we are using DownloadFileRequest object to download the combine tiff
merge tiff

Concatenate TIFF image preview

The sample TIFF images used in above example can be downloaded from DeskewSampleImage.tif and second.tiff. The final merge TIFF can be downloaded from Merged-TIFF.tiff.

Append TIF Files using cURL Commands

As our SDKs are built as per REST architecture which makes them platform independent, so they can easily be accessed via command line terminal using cURL commands. So in this section, we are going to explore the details on how to merge tiff files using cURL commands. Now the first step is to generate a JWT access token (based on client credentials) using following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

After the JWT token generation, we need to execute following command to merge TIFF images.

curl -v -X POST "https://api.aspose.cloud/v3.0/imaging/tiff/first.tiff/appendTiff?appendFile=second.tiff" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o Combined.tiff

Conclusion

This article has provided all the details to combine TIFF images online either using Java code snippet or through cURL commands. Another approach to test the promising features of API is via SwaggerUI and in case you want to modify the source code of SDK, you can download if from GitHub (all our Cloud SDKs are developed under MIT license).

Nevertheless, the Product Documentation is an amazing source of information to learn about other exciting features offered by the API Lastly, in case you encoutner any issues while using the API, you may consider approaching us for a quick resolution via free product support forum.

Please visit the following links to learn more about: