Hi,
I am working a lot recently with Assets. I want to get dimensions of the image renditions for the image. I can get the size of the rendition using getSize() method but was not able to find any method to get dimensions or say length and width of the image.
I can get the length and width of the original image from metadata tiff:ImageLength and tiff:ImageWidth but i am not seeing any information like this for renditions.
Can anyone provide any suggestions on hoe to get dimensions of the renditions.
Thanks
Solved! Go to Solution.
Try this
public int getWidth() { Asset asset = this.getResourceResolver().getResource("imagepath").adaptTo(Asset.class); Rendition rendition = asset.getRendition("cq5dam.thumbnail.48.48.png"); try { BufferedImage bimg = ImageIO.read(rendition.getStream()); return bimg.getWidth(); } catch (Exception e) { } return 0; }
Try this
public int getWidth() { Asset asset = this.getResourceResolver().getResource("imagepath").adaptTo(Asset.class); Rendition rendition = asset.getRendition("cq5dam.thumbnail.48.48.png"); try { BufferedImage bimg = ImageIO.read(rendition.getStream()); return bimg.getWidth(); } catch (Exception e) { } return 0; }
Hi
You can also try, 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();
Some more reference links:-
https://forums.adobe.com/thread/1065593
https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/commons/ImageResource.html
https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/dam/commons/util/DamUtil.html
http://cq5cms.blogspot.in/2014/07/render-image-rendtions-dynamically-in.html
http://cq5cms.blogspot.in/2014/07/renders-image-dynamically-in-cq5.html
I hope this will help you.
Thanks and Regards
Kautuk Sahni
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies