Issue facing in AEM Workflow Custom Process Step
We have written a custom workflow process that’s supposed to resize an image and create a new rendition whenever an asset is uploaded under /content/dam/projects. The code executes without throwing any errors, but the resized image isn't getting created, and I don’t see any new rendition added. Here's the snippet:
@9944223
public void execute(WorkItem workItem, Session session, MetaDataMap metaData) {
try {
String path = workItem.getWorkflowData().getPayload().toString();
ResourceResolver resolver = ...; // Get from service user or workflow session
Resource resource = resolver.getResource(path);
if (resource != null && resource.adaptTo(Asset.class) != null) {
Asset asset = resource.adaptTo(Asset.class);
Rendition original = asset.getOriginal();
try (InputStream input = original.getStream()) {
Layer layer = new Layer(input);
layer.resize(800, 600); // Resize to 800x600
asset.addRendition("custom-resized", layer.getInputStream(), "image/jpeg");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}I am not seeing any errors, but the resized rendition is not being saved. What could be the issue here?