How can I get the size or dimensions of an asset by its public ID?
Last updated: Aug-18-2026
Get asset dimensions via API
Upload response includes dimensions
When uploading using the upload endpoint of the Upload API, every upload call automatically returns a JSON response with the file's details including the bytes, width, and height parameters.
Upload an asset and read the dimensions from the response:
Example: Image upload response:
Example: Video upload response:
See also: Upload endpoint
Query assets via Admin API
If the asset is already in your product environment, use the Admin API to get the details of a single resource, including its width, height, and bytes:
For a video or audio asset, pass video as the resource type:
The response includes the video's width and height:
To also return details such as duration, frame_rate, bit_rate, and codec information, pass the media_metadata parameter in your request.
See also: Get details of a single resource
Return metadata in a client-side request using the 'getinfo' flag
You can return dimensions and other metadata about both the input asset and the transformed output asset in JSON format as a client-side request by using the getinfo flag parameter (fl_getinfo in URLs). When you add this flag, Cloudinary returns the JSON instead of delivering the transformed asset. The flag works for both images and videos, but the response format and the conditions for getting one differ between the two.
Learn more about all the getinfo options: getinfo flag
Images
For images, fl_getinfo returns JSON for any transformation, including a URL with no transformation components at all. The dimensions of the original image are returned in the input object, and the dimensions of the transformed image in the output object.
The example below shows what's returned for an image transformation that includes g_auto:
Videos
For videos, fl_getinfo returns JSON only when the transformation also includes g_auto or e_preview. Without one of those, the flag returns an empty JSON object ({}), or is ignored entirely if the URL has no other transformation components.
The response uses a flat structure rather than the nested input and output objects returned for images. The dimensions of the original video are returned as input_width and input_height, and the dimensions of the transformed video as width and height.
The example below shows what's returned for a g_auto transformation that would crop the video to 400 x 400. The cropped video isn't delivered: the flag returns this JSON instead.
width and height values describe the transformed video, so they reflect what you asked for in the URL. If your transformation sets the width and aspect ratio but not an explicit height (for example, ar_1,c_fill,g_auto,w_400), then height is returned as null and the aspect ratio is returned in ar instead. This isn't a limitation of the flag: the original dimensions are still returned in input_width and input_height. To get an explicit output height, include the h parameter in your transformation.Retrieving the JSON client-side
Because fl_getinfo is a delivery URL, you can request it directly from the browser. For example:
g_auto or e_preview transformation, use the list delivery type, which returns each asset's width and height. Note that it lists assets by tag rather than by public ID, so your assets must be tagged to be included. The list type is also restricted by default, so you need to enable it in your Security settings or use a signed URL.View asset dimensions in the Media Library
Media Library's asset preview tab
- Go to the Media Library and search for the asset.
- Select the asset and click the previous icon (eye) in the upper-right hand corner of the Media Library and under the assets toolbar.
- View the asset dimensions in the Summary tab of the Preview Pane.