My EEE is now a photoframe

I’ve never thought that I would like to have a photo-frame device until I realized I have one lying around…What got me thinking was a (not so recent) post discussing security, or lack thereof, of Kodak wireless picture frames. Until then, I didn’t even know that wireless photo-frames existed, and I can’t say I was missing this bit of information. Nonetheless, the idea of feeding a little screen in your house with content updated remotely was enough to tease my inner geek. Especially, that they give you a possibility to stream pictures from your picasa account, meaning that I didn’t have to do anything extra. What’s more important, it seemed to be quite easy to use their service without actually buying a kodak wireless picture frame (why would I want one?).So I headed to the framechannel website, created an account and started playing. One thing surprising is that they do not mention anything like API, or any other possibility of hooking up a software client to their rss feeds. Obviously, they would rather make money on the deals with frame makers than build an infrastructure for free for people like me, who are not likely to give them money. But this post is not to discuss their businessmodel, but rather to describe a way to view your pictures on any computer.The software ingredients are rather simple, I’ve used python with a few libraries, which made the task very easy:

  • feedparser to parse the rss feed (duh!)
  • pygame to show images fullscreen and control the input
  • . I’ve used their tutorial to learn the basics.

Ant that’s it. Very easy. Surprisingly nice. I can watch my kids’ photos on my eee pc without updating it: it just pulls random pictures from my picasa album. And in addition, occasionally I get weather forecasts or news from some other channels I subscribed to. And all that in about 50 lines of code.Code below is public domain (no warranty).

import pygame
from pygame.locals import *
import feedparserimport urllibURI="http://rss.framechannel.com/user=XXXX/pin=XXXX"XMAX=800YMAX=480CHANGE=pygame.USEREVENT+1DELAY=15000
def get_new_image():
    f=feedparser.parse(urllib.urlretrieve(URI)[0])
    imgURI=f['entries'][0]["link"]
    img=pygame.image.load(urllib.urlretrieve(imgURI)[0])
    orgX,orgY=img.get_size()
    if orgX>XMAX:
        dx=XMAX
        dy=int((XMAX*1.0/orgX)*orgY)
        img=pygame.transform.smoothscale(img,(dx,dy))
    if orgY>YMAX:
        dy=YMAX
        dx=int((YMAX*1.0/orgY)*orgX)
        img=pygame.transform.smoothscale(img,(dx,dy))
    return img
def main():
    pygame.init()
    screen = pygame.display.set_mode((XMAX,YMAX))#,pygame.FULLSCREEN)
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((0, 0, 0))
    screen.blit(background, (0, 0))
    pygame.display.flip()
    pygame.mouse.set_visible(0)
    clock = pygame.time.Clock()
    pygame.time.set_timer(CHANGE,DELAY)
    img=get_new_image()
    print orgX,orgY,img.get_size()
#Main Loop
    while 1:
        clock.tick(60)
        #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
                return
            elif event.type == MOUSEBUTTONDOWN or event.type == CHANGE:
                img=get_new_image()
        #Draw Everything
        screen.blit(background, (0, 0))
        screen.blit(img,(0,0))
        pygame.display.flip()
if __name__ == '__main__':
     main()
This entry was posted in But I digress..., Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">