1

I use the following code to fetch an image from a url in python :

import urllib
from PIL import Image
urllib.urlretrieve("http://www.gunnerkrigg.com//comics/00000001.jpg", "00000001.jpg")
filename = '00000001.jpg'
img = Image.open(filename)
exif = img._getexif()

However, this way the exif data is always "None". But when I download the image by hand and then read the EXIF data in python, the image data is not None. I have also tried the following approach (from Downloading a picture via urllib and python):

import urllib
f = open('00000001.jpg','wb')
f.write(urllib.urlopen('http://www.gunnerkrigg.com//comics/00000001.jpg').read())
f.close()
filename = '00000001.jpg'
img = Image.open(filename)
exif = img._getexif()

But this gives me 'None' for 'exif' again. Could someone please point out what I may do to solve this problem?

Thank you!

4

1 回答 1

0

您使用的 .jpg 不包含 exif 信息。如果您使用http://www.exif.org/samples/中的 exif 示例尝试相同的 python ,我想您会发现它有效。

于 2013-10-24T15:57:17.393 回答