user2776643
user2776643

Reputation: 23

How to get original rendition of an image uploaded in DAM using AbstractImageServlet?

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 image and height 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

The size of the original rendition of image in DAM is 2048 × 1100 and 220 KB

but the size of the image returned by the servlet after getting the layer from the original rendition is 1280*687 and 292 KB

The getLayer method of com.day.cq.wcm.foundation.Image class does not return the original rendition's exact same size.

How can we get the original image's natural size a custom servlet extending the AbstractImageServlet ?

Upvotes: 0

Views: 2206

Answers (2)

Srikant
Srikant

Reputation: 11

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-uploads.html

Upvotes: 1

Oleksandr Tarasenko
Oleksandr Tarasenko

Reputation: 1454

There is also another option of getting layer for original rendition - when you have image resource you can do next thing:

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

Upvotes: 0

Related Questions