Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Flickr Banners

If you are one of the three per­sons who ac­tu­al­ly see this blog on its site in­stead of read­ing it through some sort of ag­gre­ga­tor, you may have no­ticed I have a ban­ner.

This is what it looks like:

//ralsina.me/lateral/lateral.jpg//ralsina.me/lateral/opinion.jpg

Nice, ah?

It's not very orig­i­nal (look for "spell with flick­r" to see where I stole the idea), but I wrote a script to do it. So here it is, feel free to steal it too, it's your turn.

You will need this, Im­ageMag­ick, and a Flickr API key.

To use it sim­ply call it like this:

python banner.py something

And you will have a some­thing.jpg with some­thing in it.

#!/usr/bin/env python

import flickr,sys,random
from urllib import urlopen
import os

g=flickr.Group(id="27034531@N00")

urls = []
for l in sys.argv[1]:
  if l=="a":
    l="aa"
  if l=="i":
    l="ii"
  photos = g.getPhotos(tags=[l], per_page=50)
  urls.append(photos[random.randrange(50)].getURL(
              size='Square', urlType='source'))


for i in range(0,len(urls)):
  f=open(str(i)+'.jpg','w')
  data=urlopen(urls[i]).read()
  f.write(data)
  f.close()

os.system ("montage -tile %dx1 -geometry +0+0 %s %s"%(
            len(urls),' '.join([ '%d.jpg'%x for x in range(0,
            len(urls)) ]), sys.argv[1]+'.jpg'))

Contents © 2000-2024 Roberto Alsina