Expand my Community achievements bar.

SOLVED

Build assets image API return image rendition for a specific screen

Avatar

Level 2

I have a requirement to build an API to make available to mobile app the images stored in AEM as assets. The tricky part is that the API must return the image rendition correct for the device screen size. 
AEM have available the methods to determine the correct image rendition for the screen?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @daf99 

 

You can use ACS's Named Image Transformer, as you are thinking to create API, with this feature, you will not have to create API end you will just have to call image path with your custom transformer.

 

Refer https://adobe-consulting-services.github.io/acs-aem-commons/features/named-image-transform/index.htm...

https://varunaem.blogspot.com/2019/03/acs-commons-tools-part-1.html

 

There is similar query discussed in post https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-access-image-rendit.... This might help.

 

Thanks!

Nupur

 

 

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Hi @daf99 

 

You can use ACS's Named Image Transformer, as you are thinking to create API, with this feature, you will not have to create API end you will just have to call image path with your custom transformer.

 

Refer https://adobe-consulting-services.github.io/acs-aem-commons/features/named-image-transform/index.htm...

https://varunaem.blogspot.com/2019/03/acs-commons-tools-part-1.html

 

There is similar query discussed in post https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-access-image-rendit.... This might help.

 

Thanks!

Nupur

 

 

Avatar

Level 2

Hi @Nupur_Jain,
In first place thank you for the help.

I saw the link's that you advice, but what i am looking is a bit different.
I want to build an API that receives an image/asset identifier and some header or property with the screen size. With this 2 parameters i want to be able to get the image and the rendition that fit's the device ecran size.

For this i think that i need to have a way to calculate the rendition correct to the device screen size. AEM should have a way to do it, because it's made when we use images in portal the image used it's rendition for the screen size. My objective is to do the same implementation for this API to share the images with the mobile application.

Do you think that this possible?

Avatar

Community Advisor

@daf99 

I am not aware of such api/library available in AEM. AEM Sites pages uses adaptive images whicch basically on the fly resize the image as per image size. The is Core core Image component which you can refer to understand the functionality better.

 

I would say why don't you write your own functionality. You can use DAM asset API to get all renditions availabble for asset and on the basis of some logic, can choose better rendition.

Avatar

Level 2
Thanks for the help @Nupur_Jain, now i understand how renditions works and i realize that my approach its not possible to be done.