Hi,
I was trying similar kind of approach to generate rendtions for my image but it was creating wrong width and height ,
expecetd width and height 1600 , 800
but i got 1280X639 , what could be the possible issue , I tried passing the thhumbnail config also but no use .
Any sugesstions on this ?
@Properties({
@property(name = "process.label", value = "Custom Image Rendition Process") })
public class CustomImageRendition implements WorkflowProcess {
private static final Logger logger = Logger.getLogger(CustomImageRendition.class.getName());
protected ResourceResolverFactory resourceResolverFactory;
RenditionMaker renditionMaker;
AssetHandler assetHandler;
ResourceResolver resourceResolver;
public void execute(WorkItem workItem, WorkflowSession session, MetaDataMap args) throws WorkflowException {
try
{
String assetPath = null;
// Get the resource resolver using system user and user mapper service
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "getResourceResolver");
resourceResolver = resourceResolverFactory.getServiceResourceResolver(param);
String payloadString = workItem.getWorkflowData().getPayload().toString();
logger.info("payload path"+payloadString);
// convert the payload path into a Resource
Resource damResource = resourceResolver.resolve(payloadString);
if (damResource != null){
logger.info("the damResource is exists .. "+damResource);
// further convert the resource into Dam asset
Asset damAsset = damResource.adaptTo(Asset.class);
if(damAsset !=null)
{
logger.info("dam asset exists .. "+ damAsset);
// create a Rendition Template using Rendition Maker Api and give the width, height, quality, mimietype for your template
int width = 250;
int height = 250;
int quality = 100;
String mimeType = "image/jpeg";
String[] mimeTypesToKeep ={ "image/jpeg","image/png"};
RenditionTemplate renditionTemplate = renditionMaker.createWebRenditionTemplate(damAsset, width, height, quality,
mimeType,mimeTypesToKeep);
// Using the rendition template created above , generate the renditions
List<Rendition> renditionList = renditionMaker.generateRenditions(damAsset, renditionTemplate);
// using Asset Handler Api create thumbnails using the rendition for the asset.
Collection<ThumbnailConfig> configs = null;
for(Rendition rendition : renditionList ){
assetHandler.createThumbnails( damAsset, rendition, configs);
}
// Just to check if our rendition got added.
for (Rendition rendition2 : damAsset.getRenditions()) {
logger.info(rendition2.getName() + " " + rendition2.getPath()+"\n");
}
resourceResolver.commit();
}
}
}
catch(LoginException |IOException e){
e.printStackTrace();
}
}
}
Views
Replies
Total Likes
hi @udhayaprakash, if your goal is to create renditions without any customization to their output, such as simple resizing, I recommend checking out the Thumbnail Process step, which is part of the "DAM Update Asset" workflow. This process allows you to define both thumbnails and web-enabled images.
The advantage of this solution is that it doesn't require any code for development or maintenance, making it a better option.
WF screens:
Result:
if you're in AEM as a Cloud Service, have a look at Integrate with AEM Processing Profiles
You don’t need to create a custom code to create an image rendition. You can use available aem dam renditions to create the desired rendition both on aem on-prem and ams but in aem cloud you need to create image processing profile.
the renditions image should not be going to be larger than the original image.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies