grabbing Pictures from the web

Josh Bloom joshbloom at gmail.com
Tue Apr 10 18:38:36 EDT 2007


I don't have any experience with TK so I can't comment on that but for
getting pics from the web, you will need to do the following:
1) Work with the flickr API or flickr feeds to get the url for each picture
that you want to work with.
2) Either download the image to disk or read it into memory to work with.

Here's some sample code to open a url and save it to disk. (This is
expecting that the url points to a .jpg)

import urllib
picture = urllib.urlopen(pathToTheImageThatYouWant).readlines()
newPic = open('YourNewFile.jpg', 'wb') #Use wb as you're writing a binary
file.
newPic.writelines(picture)
newPic.close()

-Josh


On 4/10/07, Juan Vazquez < juanvazquez at gmail.com> wrote:
>
> I am new to python (2 weeks old)  and I would like to write a script that
> grabs pictures from the web (specifically flickr) and put them on a Tk
> Canvas for a slide show/editing program. my 2 questions are
> 1) How do I grab a picture from the web
> 2) is the use of the Tk canvas for working with the picture the best
> approach?
>
> Any help or references to resources that point me in the right direction
> would be greatly appreciated. Thanks in Advance.
> -Juan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070410/18e7a299/attachment.html>


More information about the Python-list mailing list