Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
dnaz
2 years agoExplorer | Level 3
How can I get images width and height values in pixel with API V2
I have created an api with PHP language, I can connect list folders and files etc.. But I cant get the images width and height with api, How can I do this with the latest api documentation ?
https://www.dropbox.com/developers/documentation/http/documentation
I have sent request with
"include_media_info": true
But there is no values depends on the width and height of images, How can I solve this ?
10 Replies
- Здравко2 years agoLegendary | Level 20
Hi dnaz,
To get image or video media info in metadata you need to call /2/files/get_metadata endpoint. The media info is not supported on other endpoints for number of years already.
Hope this helps.
- dnaz2 years agoExplorer | Level 3
Hi, I have used it but cant get the width and height.
- Здравко2 years agoLegendary | Level 20
I just tried for an arbitrary image and its as follows (a bit shortened for clarity):
> POST /2/files/get_metadata > Host: https://api.dropboxapi.com > User-Agent: api-explorer-client > Authorization: Bearer ***********valid*access*token******** > Content-Type: application/json > > {"path":"/IMG_20230616_150044.jpg","include_media_info":true} < HTTP/2 200 < content-type: application/json < server: envoy < content-length: 568 < < {".tag": "file", "name": "IMG_20230616_150044.jpg", "path_lower": "/img_20230616_150044.jpg", "path_display": "/IMG_20230616_150044.jpg", "id": "id:ElL7W-JPrdMAAAAAAABaqQ", "client_modified": "2023-06-16T12:01:28Z", "server_modified": "2023-06-16T12:01:29Z", "rev": "5fe3df1f1b42b22ab554a", "size": 1649795, "media_info": {".tag": "metadata", "metadata": {".tag": "photo", "dimensions": {"height": 4000, "width": 1840}, "time_taken": "2023-06-16T15:00:44Z"}}, "is_downloadable": true, "content_hash": "a373008e6d8daf0d0823cd623d38a949548d26d08f42a779cbf8ebde12c213cc"}As can be seen both width and height are there. What exactly doesn't work for you?
- dnaz2 years agoExplorer | Level 3
I'm gettin this:
I'm using PHP Curl,
object(stdClass)#1 (11) { [".tag"]=> string(4) "file" ["name"]=> string(7) "S3x.png" ["path_lower"]=> string(37) "/vhq dxf/k-s-mr-archive/03-29/s3x.png" ["path_display"]=> string(37) "/VHQ DxF/K-S-MR-ARCHIVE/03-29/S3x.png" ["id"]=> string(25) "id:TvyxEphAjwwAAAAAAADawQ" ["client_modified"]=> string(20) "2024-03-29T17:50:47Z" ["server_modified"]=> string(20) "2024-04-03T23:19:39Z" ["rev"]=> string(31) "016153974e96a70000000010ef1" ["size"]=> int(12209354) ["is_downloadable"]=> bool(true) ["content_hash"]=> string(64) "3667ae13d1bd27da44f59c4c88bd69041fe0f95d8119bec35851a144759" } - Здравко2 years agoLegendary | Level 20
😀 I'm receiving roughly the same (or equivalent) when I skip turning on the media info. Did you skip that step? (Note in the request body above: "include_media_info":true) 👆 By default media info is off!
Hope this clarifies matter.
- dnaz2 years agoExplorer | Level 3
yes 🙂
My url : $url = 'https://api.dropboxapi.com/2/files/get_metadata';
My curl post data = $data = '{"include_media_info": true,"path": "/VHQ DTF/K-S-MR-ARCHIVE/03-29/S37.png"}';
but I'm getting same results that without dimensions 🙂
- Здравко2 years agoLegendary | Level 20
Wow.. Yes, you are correct. As seems it works stable only for jpegs, but not png or gif.... Don't ask me why! 🤷
- Greg-DB2 years ago
Dropbox Community Moderator
This media information is not available for all files/file types, but I'll pass this along as a feature request to expand support for this. I can't promise if or when that might be done though.
- Здравко2 years agoLegendary | Level 20
Hi Greg-DB,
Expanding support for different media types would be really fine, but regardless of the final decision for whether and/or when that to be done, documentation may be improved. 😉 At present definition of what's photo and what's video in content of type MediaMetadata is missing and predisposes confusions! (I just got confused above, for instance 😖😳) Would be fine definition like the one existing for file types related to Dropbox Chooser to be added that would clarify things.
Have a nice day.
- Greg-DB2 years ago
Dropbox Community Moderator
Здравко Thanks! I'll pass this along as well.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!