Resize Assets using Asset Compute Worker | Community
Skip to main content
Level 3
February 11, 2025
Solved

Resize Assets using Asset Compute Worker

  • February 11, 2025
  • 3 replies
  • 732 views

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 


Best answer by sarav_prakash

@vishal33 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. 

3 replies

Adobe Employee
February 20, 2025

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/deploy/runtime

 

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

sarav_prakash
Community Advisor
Community Advisor
March 8, 2025

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.

 

 

sarav_prakash
Community Advisor
sarav_prakashCommunity AdvisorAccepted solution
Community Advisor
April 8, 2025

@vishal33 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. 

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 8, 2025

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/deploy/runtime 

 

Hope this helps.

Esteban Bustamante