How to extract a filename from a URL & append a word to it?
I have the following url:
url = http://photographs.500px.com/kyle/09-09-201315-47-571378756077.jpg
I would like to extract the file name in this url:
09-09-201315-47-571378756077.jpg
Once I get this file name, I'm going to save it with this name to the
Desktop.
filename = **extracted file name from the url**
download_photo = urllib.urlretrieve(url, "/home/ubuntu/Desktop/%s.jpg" %
(filename))
After this, I'm going to resize the photo, once that is done, I've going
to save the resized version and append the word "_small" to the end of the
filename.
downloadedphoto = Image.open("/home/ubuntu/Desktop/%s.jpg" % (filename))
resize_downloadedphoto = downloadedphoto.resize.((300, 300), Image.ANTIALIAS)
resize_downloadedphoto.save("/home/ubuntu/Desktop/%s.jpg" % (filename +
_small))
From this, what I am trying to achieve is to get two files, the original
photo with the original name, then the resized photo with the modified
name. Like so:
09-09-201315-47-571378756077.jpg
09-09-201315-47-571378756077_small.jpg
How can I go about doing this?
No comments:
Post a Comment