Expand my Community achievements bar.

Resize Assets using Asset Compute Worker

Avatar

Level 3

Hi,
we have a requirement to resize assets, for which we are using an Assets Compute worker with the "JIMP" library. However we are facing an error stating:
Asset Compute worker failed to generate rendition for asset '/content/dam/test-custom-asset-renditions/example.jpg', \, Reason: 'GenericError', Message: 'Call to custom worker https://example-development.adobeioruntime.net/api/v1/web/dx-asset-compute-worker-1/worker failed with: 400 Bad Request'.
Code:

'use strict';

const { worker, SourceCorruptError} = require('@adobe/asset-compute-sdk');
const fs = require('fs').promises;
import { Jimp } from 'jimp';

exports.main = worker(async (source, rendition) => {
    const stats = await fs.stat(source.path);
    if (stats.size === 0) {
        throw new SourceCorruptError('source file is empty');
    }
    console.log("Source Path is-->" + source.path);
    console.log("rendition Path is-->" + rendition.path);

    // Read/parse and validate parameters
    const SIZE = parseInt(rendition.instructions.size) || 800;
    (await Jimp.read(source.path)).resize({w:SIZE,h:SIZE}).write(rendition.path);
  
});


please help us solve the error and let us know if you require any further details
Thanks,

@EstebanBustamante 
@arunpatidar 
@Harwinder-singh 
@sravs 
@abhishekanand_
@tmj 


Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Employee

Please make sure you provide the correct URL in AEM custom processing profile.

After deploying the custom worker, you can retrieve the correct url using "aio app get-url" 

More details here: https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/asset-compute/depl...

 

In this case the url seems like a Bad request: https://example-development.adobeioruntime.net/api/v1/web/dx-asset-compute-worker-1/worker 

Avatar

Community Advisor

Please refer to Troubleshooting guide. One possible reason is memorySize limit too low. Check your manifest.yml. Default settings is 256MB. If you are processing heavier assets, and if worker fails due to memory, it ll still throw 400 bad request.