I'd like to get only landscape photos from Flickr but I don't see any parameters that lets me do that. Does anyone know if there's a way?
In the response from the flickr.photos.search
feature, you can specify a number of optional parameters know as extras
. For each URL (in format of url_s,url_q
...) extra that you specify you'll get the following information.
Sample JSON Reponse
{
...
"photos": {
"page": 1,
"pages": "478",
"perpage": 2,
"total": "4775",
"photo": [
{
...
"longitude": 0, "accuracy": 0, "context": 0, "media": "photo",
"media_status": "ready",
"url_q": "https:\/\/farm4.staticflickr.com\/0000\/000_000_q.jpg",
"height_q": "150",
"width_q": "150",
...
},
{
...
"longitude": 0, "accuracy": 0, "context": 0, "media": "photo",
"media_status": "ready",
"url_q": "https:\/\/farm4.staticflickr.com\/0000\/000_111_q.jpg",
"height_q": "150",
"width_q": "150",
...
},
] },
"stat": "ok"
};
If you want the URL for the Q sized photo, you will have the height_q
and width_q
attributes. If width_q
is greater than height_q
the orientation is landscape. If it's the opposite the orientation of the photo is portrait, otherwise it's a perfect square.
In Javascript you could write a function like this:
function determinePhotoOrientation(width, height) {
if (width > height) {
return 'landscape';
} else if (width < height) {
return 'portrait';
}
return 'square';
}
If you are using a different language you can make a similar function in that language to help you determine the orientation.