Resize Assets using Asset Compute Worker
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


