Christian Heilmann

Posts Tagged ‘photos’

TTMMHTM: Obama and unicorns,3D reconstruction from Flickr photos,quick brown foxes,CSS colours and rotations and new apples

Wednesday, July 29th, 2009

Things that made me happy this morning:

Got photos of the British Museum? Help me say ‘sorry’ to Jinho on behalf of London

Thursday, May 14th, 2009

I love London – it is my choice of home. That’s why I get very upset when the first impression people get of it is something that drags people down. If you’ve been at Open Hack 2009 in Covent Garden last weekend you might have stumbled upon this man:

Yahoo Open Hack London 317 by  Jinho.Jung.

This is Jinho Jung, a Yahoo Developer Network colleague from South Korea who came over for hack day to see what the UK hackers are all about. He also did a sterling job covering the whole event and especially the price giving with his camera (others, of course are James Broad and Steve Marshall).

Whilst waiting for his food at some burger joint in Soho, Jinho had his camera stolen the day after hack day. Losing 2000 dollars of equipment is bad enough but what really made Jinho sad is that he had taken around 300 photos of the British Museum which he lost with the camera. This is doubly annoying as you cannot take photos in museums in Seoul and he was very elated about the rules in this country.

So, as a sign, could you please tag great photos of the British Museum and especially its exhibits with “sorryjinho or add it to this group to show him that London is a great place to visit and we’re happy to fill the gap of lost memories? Let’s show that London photographer colleagues have s(e)oul (ok, I am ashamed already of this one).

Chris Heilmann

Searching Flickr photos by license and text and returning defined sizes made easy with YQL

Saturday, February 14th, 2009

We (Nagesh Susarla and moi) are just sitting here at Open Hack Day in Bangalore, India and geek out on YQL trying to find how far we can push it to make the life of a hacker easier.

One of the things was using Flickr photos and making sure we can only get photos of a certain license for a certain text. Here’s the magic we YQL statement we came up with:

select * from flickr.photos.sizes where photo_id in (select id from flickr.photos.search(20,20) where text=@text and license=@license)  and label=@label

The (20,20) means “get me 20 photos starting at the 20th” and to make it easier say we do the first 50 results instead. The @parameter are placeholders which will be replaced by URL parameters.

As a URL you can use this and send the right parameters, for example find cats with an attribution license and only square photos (75×75pixels):

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from flickr.photos.sizes%20where%20photo_id%20in%20(select%20id%20from%20flickr.photos.search(50)%20where%20text%3D%40text%20and%20license%3D%40license)%20and%20label%3D%40label&format=xml&text=cats&license=4&label=Square

Possible licenses are:

1 Attribution-NonCommercial-ShareAlike License
2 Attribution-NonCommercial License
3 Attribution-NonCommercial-NoDerivs License
4 Attribution License
5 Attribution-ShareAlike License
6 Attribution-NoDerivs License
7 No known copyright restrictions

Possible labels are Square,Thumbnail,Small,Medium and Original

To make it easier, you can also wrap the whole thing in a method:

function display(o){
var out = ‘’;
for(var i=0;i var cur = o.query.results.size[i];
out+=’‘;
}

var d = document.createElement(‘div’);
d.innerHTML = out;
document.body.appendChild(d);
}

/*
leechFlickr() by Christian Heilmann
Gets an object as the parameter. Object properties:
query (mandatory) – term to search flickr for
amount – amount of photos (defaults to 20)
license – 1 to 7
label – Square,Thumbnail,Small,Medium and Original
callback – callback function name as string

*/
function leechFlickr(o){
if(o.query){
var amount = o.amount || 20;
var license = o.license || 4;
var url = ‘http://query.yahooapis.com/v1/public/yql?’ +
‘q=select%20*%20from flickr.photos.sizes’ +
‘%20where%20photo_id%20in%20(select’ +
‘%20id%20from%20flickr.photos.search(’ +
amount + ‘)%20where%20text%3D%40text%20and’ +
‘%20license%3D%40license)’;
if(o.label){
url += ‘%20and%20label%3D%40label’;
}

url += ‘&format=json&callback=’ + o.callback +
‘&text=’ + o.query + ‘&license=’ + license;
if(o.label){
url += ‘&label=’ + o.label;
}

var s = document.createElement(‘script’);
s.src = url;
document.getElementsByTagName(‘head’)[0].appendChild(s);
}

}

leechFlickr(
{

query:’cats’,
label:’Square’,
callback:’display’
}

);
leechFlickr(
{

query:’parrots’,
amount:10,
license:3,
label:’Square’,
callback:’display’
}

);

See the code in action and download the script.

Does YQL rock or what? No messy user IDs, no mixing and matching all kind of API methods, just plain yummy data.