Expand my Community achievements bar.

Get original rendition of an image uploaded in DAM using AbstractImageServlet

Avatar

Level 4

We have written a custom servlet by extending the AbstractImageServlet and registered it against a custom selector and we are overriding the createLayer method . Returning a layer either from the image or after getting the layer from original rendition of the image does not return the original size of the image

Image img=new Image(imageContext.resource); Layer layer=img.getLayer(true, true, true); return layer;

or

Resource imgResource = imageContext.request.getResourceResolver() .getResource(imagePath); Layer layer=imgResource.getLayer(true, true, true); return layer;

where imagePath is the path of original rendition of the image

or 

Asset asset = imageResource.adaptTo(Asset.class); Rendition original = asset.getOriginal(); Layer layer = new Layer(original.getStream());

 

The size of the original rendition of image in DAM is 258 KB

but the size of the image returned by the servlet after getting the layer from the original rendition is 713KB. The height and width are the same as original rendition (2048*1100)

As per our understanding; the layer returned from the original rendition of image through custom servlet should have the exact same height;width and size as that of the original rendition in DAM.

How can we get the original image's natural size by extending the AbstractImageServlet ?

Edit: Used  getLayer(false, false, false);

It also returns the same result.

3 Replies

Avatar

Level 10

"

The height and width are the same as original rendition (2048*1100)

As per our understanding; the layer returned from the original rendition of image through custom servlet should have the exact same height;width and size as that of the original rendition in DAM

"

You question is not clear - you state both height and width are the same. 

Avatar

Level 4

The dimensions; height and the width are the same as original rendition but the image size is not same; it is 258 KB in DAM and 713 KB returned by the servlet. The size in kbs of the image returned by the servlet should also be the same as the size in kbs of the original rendition?

Avatar

Level 1

We will face the above situation, when the uploaded image has a width more than 1280px. AbstractImageServlet.ImageContext has a layer of max width 1280px. As you have uploaded an image of width 2048px, it's resized. If you try an image having width less then 1280px, it will not be resized.

However, you have to update the one service in system configurations and one DAM asset workflow step to make it work.

Configuration: Day CQ DAM Buffered Image Cache Property: Max Dimension "2048x2048"

Workflow Step: DAM Update Asset: Process Thumbnails: Web Enabled Image: Width- 2048 and height- 2048.

for more details please look into below links:

https://helpx.adobe.com/experience-manager/kb/remove-web-rendition-dimension-limit.html

https://helpx.adobe.com/experience-manager/kb/cqbufferedimagecache-consumes-heap-during-asset-upload...