Hi
I am trying to crop an image programatically
Resource res = resourceResolver.getResource("/content/dam/images/test.jpg");
Asset asst = res.adaptTo(Asset.class);
Resource dataResource = resourceResolver.getResource(res.getPath()+"/jcr:content/renditions/original/jcr:content");
Layer layer = ImageHelper.createLayer(currentNode.getSession(),asst.getCurrentOriginal().getPath());
log.error("LAYER**" + layer);
Rectangle rect = ImageHelper.getCropRect("0,0,100,100",res.getPath());
layer.crop(rect);
But I am not able to do the same since I am getting null pointer exception , since the layer itself is null. Can I know where I am making a mistake
Thanks
Veena
Solved! Go to Solution.
Views
Replies
Total Likes
can you post the exact stack trace... the blog post uses ImageHelper.createLayer(dataResource)
asset.getCurrentOriginal() is deprecated - https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/dam/api/Asset.html#getCurrentO...()
getOriginal()
instead.
Rendition
representing the asset's rendition currently marked as the asset's unmodified, original version. A rendition is marked as the original of an asset via the existence of the propertycurrentOriginal on the asset's content node. The property contains the path of the rendition to be considered the original. E.g. /content/dam/geometrixx/banners/banner-mono.png/jcr:content/currentOriginal with value /content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions/myOriginal.Views
Replies
Total Likes
Also, just verify if you are importing a right 'Layer' package.
Views
Replies
Total Likes
See this community article - it talks about using this API:
http://experience-aem.blogspot.ca/2014/01/aem-cq-56-crop-images-in-workflow-step.html
Hope this helps.
Views
Replies
Total Likes
Hi Scott,
I followed the same article , but I am getting Null for
Layer layer = ImageHelper.createLayer(currentNode.getSession(),asst.getCurrentOriginal().getPath());
Views
Replies
Total Likes
Hi Bsloki
I am using com.day.image.Layer
Views
Replies
Total Likes
Hi Veena,
Can you please debug or put sysout and check which exactly is coming as null.
It might be ImageHelper, Session or the path
Views
Replies
Total Likes
can you post the exact stack trace... the blog post uses ImageHelper.createLayer(dataResource)
asset.getCurrentOriginal() is deprecated - https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/dam/api/Asset.html#getCurrentO...()
getOriginal()
instead.
Rendition
representing the asset's rendition currently marked as the asset's unmodified, original version. A rendition is marked as the original of an asset via the existence of the propertycurrentOriginal on the asset's content node. The property contains the path of the rendition to be considered the original. E.g. /content/dam/geometrixx/banners/banner-mono.png/jcr:content/currentOriginal with value /content/dam/geometrixx/banners/banner-mono.png/jcr:content/renditions/myOriginal.Views
Replies
Total Likes