Search code examples
jspjstladobeaemdam

CQ5 - Get DAM image width and height for programmatic use


I have images in the DAM in CQ5 and I need to access the width and height of these images inside a .jsp for programmatic use.


Solution

  • You can use the AssetDetails class to get the details of a particular DAM Asset.

    For e.g.,

    Resource res = resourceResolver.getResource("<<path to resource>>"); 
    AssetDetails assetDetails = new AssetDetails(res);
    assetDetails.getHeight();
    assetDetails.getWidth();