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.

4 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.

 

 

Avatar

Community Advisor

@Vishal_Jain03 wer you able to resolve? Start with a easy small asset and check if worker runs. If Worker fails to call a small asset, then workercode problem. But if small asset works and heavy asset fails, then its worker size. 

Now workers are supposed to small, shortlived and run concise. If longrunning process expected, adobe provides 2 ways 

https://developer.adobe.com/runtime/docs/guides/using/asynchronous_calls/

 

Tip: First one was the easiest , I got it working for me. Second way, doesnt work as documented. 

Avatar

Community Advisor and Adobe Champion

Hi, 

It's possible that you are trying to invoke a worker that isn't fully deployed, the URL might be incorrect, or some necessary parameters are missing. Check this on how to deploy runtime functions to validate everything is ok: https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/asset-compute/depl... 

 

Hope this helps.



Esteban Bustamante