Copy link to clipboard
Copied
async function createPsdWithMultipleLayers(srcUrls, headers, outputUrl, width, height) {
try {
const api_url = 'https://image.adobe.io/pie/psdService/documentCreate';
const inputs = srcUrls.map((url, index) => ({
type: "layer",
input: {
storage: "external",
href: url
},
name: `Layer ${index + 1}`
}));
const payload = {
options: {
document: {
height: height, // Use received height
width: width, // Use received width
resolution: 72,
fill: "transparent",
mode: "rgb"
},
layers: inputs
},
outputs: [{
href: outputUrl,
storage: "external",
type: "image/vnd.adobe.photoshop",
overwrite: true
}]
};
console.log("Final payload to Adobe API:", JSON.stringify(payload));
console.log("Headers for Adobe API call:", JSON.stringify(headers));
const response = await axios.post(api_url, payload, { headers: headers });
console.log("Status from Adobe API:", response.status);
console.log("inFunction: Response from Adobe API:", JSON.stringify(response.data));
return response.data;
} catch (error) {
console.error('Error creating PSD with layers:', error);
throw new Error('Error creating PSD with layers');
}
}
I am not a coder, so can't comment on your code directly, but a quick question for you. Are your 400kb images jpegs? If so each is highly compressed and much smaller than when opened in memory.
An uncompressed 6 layer doc in Photoshop of the size you describe and in 8 bits/channel would take 1920 x 1000 x 3bytes x 6 layers = 34,560,000 bytes in RAM.
When saving a PSD from that RAM data two settings in Preferences file handling come into play. One is 'Disable Compression of PSD and PSB files'.
...Find more inspiration, events, and resources on the new Adobe Community
Explore Now