Skip to main content
Participant
May 25, 2024

Create Document endpoint - file size

  • May 25, 2024
  • 1 reply
  • 399 views
Hi,
 
I am using the create document endpoint to pass in 6 images of size ~400 kb each and the psd file I get back is about 34 mb. 
 
Any ideas why this is happening and how can I control it? I tried to read the documentation and searched the internet but found nothing that could help me.
 
My function to create psd is as follows. Width is always 1920, height is 1000 and resolution is 72
I have also attached my input files and the resulting psd
 
 
 

 

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');
    }
}

 

 
Any help would be much appreciated.
 
Thanks

1 reply

davescm
Community Expert
Community Expert
November 17, 2024

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'. With that checked your 34MB in memory is going to take up the same disk space, probably a little more due to metadata. With compression on, the file will be smaller but probably not as small as teh lossy compression used in jpegs.
The second is Maximise PSD and PSB File Compatibilty. If that is set to 'always' an addition layer is added within the file which is a flattened version of the image layers. That again adds to the file size.

 

Dave