Dynamic Media URL response byte-size

This article explains how to get the DM asset binary size while displaying the original rendition from a URL in Dynamic Media Classic.

Description description

Environment

Dynamic Media Classic

Issue

Unlike AEM URLs which are static, DynamicMedia URLs are parsed, evaluated, and responded to at runtime on the fly. For example, the following returns a 400x400 image:

https://s7d1.scene7.com/is/image/TechSupport/Backpack?wid=400

But if you want just one pixel bigger, you can request:

https://s7d1.scene7.com/is/image/TechSupport/Backpack?wid=401

Further, if you want the background red, you can request:

https://s7d1.scene7.com/is/image/TechSupport/Backpack?bgc=255,0,0

Any of these changes will alter the bytesize of the image.

Most likely, the only way to know the size of the image returned is to parse the response header “content-length” for any 200 responses.

Resolution resolution

The header referred to in the above section is this on Mozilla.org: Content-Length

There should be a sample code to extract it, for example, refer to this link here on Stackoverflow. But note that this example is not Adobe code, so you might want to find a reliable source of code and use that instead.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f