Query or report showing byte-lengths and pixel-sizes of All image renditions in Digital Assets | Community
Skip to main content
Level 4
January 24, 2017
Solved

Query or report showing byte-lengths and pixel-sizes of All image renditions in Digital Assets

  • January 24, 2017
  • 2 replies
  • 1680 views

Hi All,

Is it possible in AEM 6.1 to see a list showing byte-lengths and pixel-sizes of All image renditions in Digital Assets?

Is there a query or report built in to AEM 6.1 that can do this?   Or is it possible to do this in JAVA?

In CRXDE Lite, the following SQL2 query will list all files in Digital Assets, but includes files which are not images :-

    SELECT * FROM [dam:Asset] WHERE ISDESCENDANTNODE("/content/dam")

But the following SQL2 quary returns no results :-

    SELECT * FROM [dam:Asset] AS d WHERE d.[jcr:content/renditions] IS NOT NULL

Alternatively the URL http://localhost:4522/bin/querybuilder.json?path=%2fcontent%2fdam&p.limit=-1 does return a lot of data in JSON format but at the bottom of the data it says Exception: StackOverflowError.

Thank you for your time.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

The image details are stored under metadata/dam:size property . 

For extending search , you need to create a custom facet to search dam based on asset size . 

1. What is the best approach to create a custom facet ? 

I try overlaying /libs/cq/ui/widgets/source/widgets/wcm/PropertyPredicate.js and customized the Propertypredicate.js javascript as per your requirement .

2.Now ,you need to create JCR Predicate expression to genarate XPATH query . Please find a sample predicate expression 

http://localhost:4502/libs/cq/search/content/querydebug.html 

type=dam:Asset
property=jcr:content/metadata/dam:size
property.value = 42018

How to add operators to the predicate expression to generate below XPATH

//element(*, dam:Asset)
[
jcr:content/metadata/@dam:size<42018 
]

I Hope this will work for you.

~kautuk

2 replies

smacdonald2008
Level 10
January 24, 2017

You would have to write a custom service to do this. You would need to query for the DAM assets using JCR SQL2 or QUeryBuilder then write Java logic to get at the byte information that you want. AEM does not support this out of the box. 

See - this will point you in the right direction:

http://stackoverflow.com/questions/9551900/how-to-get-image-real-byte-size

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
January 30, 2017

The image details are stored under metadata/dam:size property . 

For extending search , you need to create a custom facet to search dam based on asset size . 

1. What is the best approach to create a custom facet ? 

I try overlaying /libs/cq/ui/widgets/source/widgets/wcm/PropertyPredicate.js and customized the Propertypredicate.js javascript as per your requirement .

2.Now ,you need to create JCR Predicate expression to genarate XPATH query . Please find a sample predicate expression 

http://localhost:4502/libs/cq/search/content/querydebug.html 

type=dam:Asset
property=jcr:content/metadata/dam:size
property.value = 42018

How to add operators to the predicate expression to generate below XPATH

//element(*, dam:Asset)
[
jcr:content/metadata/@dam:size<42018 
]

I Hope this will work for you.

~kautuk

Kautuk Sahni