image rendtion not created properly | Community
Skip to main content
New Participant
March 21, 2025
Solved

image rendtion not created properly

  • March 21, 2025
  • 2 replies
  • 489 views

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({

@2542150(name = "process.label", value = "Custom Image Rendition Process") })

@8220494

@1790552

 

public class CustomImageRendition implements WorkflowProcess {

 

  private static final Logger logger = Logger.getLogger(CustomImageRendition.class.getName());

 

  @3214626

  protected ResourceResolverFactory resourceResolverFactory;

 

  @3214626

  RenditionMaker renditionMaker;

 

  @3214626

  AssetHandler assetHandler;

 

  ResourceResolver resourceResolver;

 

  @9944223

  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();

  }

  }

 

}

Best answer by DPrakashRaj

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.

2 replies

DPrakashRaj
DPrakashRajAccepted solution
New Participant
March 21, 2025

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.

giuseppebaglio
New Participant
March 21, 2025

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:

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/dam/core/process/CreateThumbnailProcess.html 

if you're in AEM as a Cloud Service, have a look at Integrate with AEM Processing Profiles