How to Convert Images to PSD (PhotoShop) Format
For those images we want to fine-tune within the PhotoShop application, switching formats to .PSD is a logical first step.
Using the below code, we can take advantage of a free API in our Node.js applications that will convert dozens of unique image formats — including everything from PNG and JPG to TIFF, WEBP and PDF — into PhotoShop PSD format. We can use this conversion service for free with a free-tier API key; this will allow a limit of 800 API calls per month with no additional commitment.
We can start out by installing the SDK. We can either run the following command:
npm install cloudmersive-image-api-client --save
Or we can add this snippet to our package.json:
"dependencies": {
"cloudmersive-image-api-client": "^1.3.4"
}
Lastly, we can incorporate the below code into our file & call the function:
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.convertToPhotoshop(imageFile, callback);
Now we can easily convert our images to .PSD without so much as a glance at the original format. Easy!