We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
lrduques
6 years agoHelpful | Level 6
How to display thumbnails in it's original size with PHP
Hi!
I am trying to display my Dropbox images on the browser using /get_thumbnail which works just fine.
However, the image on the browser it's too small. It's not the original size.
This is the png image on my Dropbox account:
And this is the same image I got from the API:
As you can see, it's impossible to see the image.
So anyone knows how do I get the image in it's original size? I am using a PHP code as follow to browser the images:
<?php require_once 'Functions/functions.php'; header("Content-Type: image/jpeg"); $token = getToken($_SESSION['uid']); if (isset($token[0])) { //$data = file_get_contents('json/getThumbnail.json'); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token[0]->itoken, 'Dropbox-API-Arg: {"path": "/test-1/Capture-desktop.PNG", "format": "png", "mode": "strict"}')); curl_setopt($ch, CURLOPT_URL, "https://content.dropboxapi.com/2/files/get_thumbnail"); $response = curl_exec($ch); echo $response; }else{ header('Location: http://localhost/optiSurface-dropbox/curl-auth1.php'); exit(); } ?>
I appreciate if anyone can help me out with this issue.
Cheers!!
By default, the /2/files/get_thumbnail endpoint will return a 64x64 thumbnail of the requested image. If you want a different size, you can request it using the "size" parameter. You can specify that the same way you specify the "mode" and "format" parameters. You can find more information, such as the sizes that are available, in the /2/files/get_thumbnail:
https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
Note that if you want the original file data though, you can instead use /2/files/download:
https://www.dropbox.com/developers/documentation/http/documentation#files-download
Problem solved!!
I read a little further the documentation I figured out that I was missing the paramenter size on my code.So I changed this line:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token[0]->itoken, 'Dropbox-API-Arg: {"path": "/test-1/Capture-desktop.PNG", "format": "png", "mode": "strict"}'));
For this one:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token[0]->itoken, 'Dropbox-API-Arg: {"path": "/test-1/Capture-desktop.PNG", "format": "png", "size": "w1024h768", "mode": "strict"}'));
The size options I found in this link: https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
And now it's working perfectly!
Cheers!!
- Greg-DBDropbox Staff
By default, the /2/files/get_thumbnail endpoint will return a 64x64 thumbnail of the requested image. If you want a different size, you can request it using the "size" parameter. You can specify that the same way you specify the "mode" and "format" parameters. You can find more information, such as the sizes that are available, in the /2/files/get_thumbnail:
https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
Note that if you want the original file data though, you can instead use /2/files/download:
https://www.dropbox.com/developers/documentation/http/documentation#files-download
- lrduquesHelpful | Level 6
Problem solved!!
I read a little further the documentation I figured out that I was missing the paramenter size on my code.So I changed this line:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token[0]->itoken, 'Dropbox-API-Arg: {"path": "/test-1/Capture-desktop.PNG", "format": "png", "mode": "strict"}'));
For this one:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token[0]->itoken, 'Dropbox-API-Arg: {"path": "/test-1/Capture-desktop.PNG", "format": "png", "size": "w1024h768", "mode": "strict"}'));
The size options I found in this link: https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail
And now it's working perfectly!
Cheers!!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 8 hours agoIf 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 or Facebook.
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!