Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Get original rendition of an image uploaded in DAM using AbstractImageServlet

Avatar

Level 1

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 

Tried with below:

@Override
    protected void writeLayer(SlingHttpServletRequest request, SlingHttpServletResponse response, ImageContext context, Layer layer) 
            throws IOException, RepositoryException {
        double quality;
        quality = 0.8;//getImageQuality();
        LoggerUtil.debugLog(this.getClass(),"Image Quality is {}",quality);
        writeLayer(request, response, context, layer, quality);
    }

Updated Quality with 0.5  but still we are getting increases size of the image than orginal size. Width & Height of the image is same but the size is more.

 

Could you please help me.

6 Replies

Avatar

Level 10

I am looking to see if we can find an example for you. 

Avatar

Level 10

See the example here - it may point you in the correct direction of working with AbstractImageServlet: 

http://cq5cms.blogspot.ca/2014/07/render-image-rendtions-dynamically-in.html

Avatar

Level 10

Here is feedback from our team: 

They could take a look at the NamedImageTransformServlet .. its sort of a variation of the AbstractImageServlet and provides a customizable rendition picker (so you could configure via OSGi the picker to be ‘original’ and have that picked as the source image.)

https://github.com/Adobe-Consulting-Services/acs-aem-commons/tree/master/bundle/src/main/java/com/ad...

Avatar

Level 1

Thank you @smacdonald2008

I will try with this & let you know if any :) 

Thank you very much. 

Avatar

Community Advisor

@basetti, jvm 1.8 and trying to decrease size of .png?

 

Regards,

Peter