How to Convert Images to TIFF Format in Node.js

Cloudmersive
2 min readNov 22, 2023

--

If we’re planning to print graphics, logos, or other images, converting our images to TIFF is a great option.

Using the below code, we can take advantage of a free API to make our conversion from dozens of common image formats to TIFF format. We can easily incorporate this API into any of our Node.js applications, and we can authorize our API calls using a free-tier API key (these allow a limit of 800 API calls per month and no commitment).

To get started, let’s install the SDK. We can do that in one of two ways — either by running this command:

npm install cloudmersive-image-api-client --save

Or by adding this snippet to our package.json:

  "dependencies": {
"cloudmersive-image-api-client": "^1.3.4"
}

Lastly, we can call the function using the below code & complete our API call:

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');
var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveImageApiClient.ConvertApi();

var imageFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.convertToTiff(imageFile, callback);

Just like that, we can easily convert our images to TIFF.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet