How to Convert Images to Photoshop (PSD) Format using JavaScript
Switching images to proprietary image formats at scale can be a real pain. If you’re using Photoshop to process large numbers of images for web content (or any reason), give our PSD Conversion API a try. With this operation included in your app/website as an API service, you can quickly convert dozens of common input image file types into PSD in the blink of an eye, ensuring those images are ready for immediate use within the Adobe Photoshop platform. The best part? You can use this API for free when you register a free account on our website & receive the necessary API key. Once you do, use the below code examples to structure your API call in JavaScript (alternatively, you can find other code examples available on our API Console page, or use this API as a connector action in Power Automate & Logic Apps).
Let’s start by demonstrating the code you’ll need to call this API using the XHR feature in JavaScript:
var data = new FormData();
data.append("imageFile", fileInput.files[0], "file");
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});xhr.open("POST", "https://api.cloudmersive.com/image/convert/to/psd");xhr.setRequestHeader("Apikey", "YOUR-API-KEY-HERE");xhr.send(data);
To install jQuery instead, first run the below command:
bower install jquery
Then structure your API call like so:
var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");var settings = {
"url": "https://api.cloudmersive.com/image/convert/to/psd",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};$.ajax(settings).done(function (response) {
console.log(response);
});