View Single Post
Old 03-28-2012, 12:37 PM   #3
RobFreundlich
Connoisseur
RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.RobFreundlich ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 10000010
Join Date: Jan 2012
Device: Android Tablet with Calibre Companion and Moon+ Reader Pro
Thanks - that helps me move forward a bit.

PIL.Image doesn't seem to like URLs for filenames, so I wrote the following script to fetch the image:

Code:
import string
import mechanize
from PIL import Image

br = mechanize.Browser()
response = br.open("http://www.bostonglobe.com/rf/image_960w/Boston/2011-2020/2012/03/27/BostonGlobe.com/EditorialOpinion/Images/03.28ROMNEYHOUSE.tif")
data = response.get_data()

print data[0:32]

f = open("image.tif", "wb")
f.write(data)
f.close()

im = Image.open("image.tif")
print "Format:", im.format, ", Mode:", im.mode, ", Size:", im.size
It outputs the following:

Code:
\377\330\377\340^@^PJFIF^@^A^A^@^@^A^@^A^@^@\377\355^@,Photosho
Format: JPEG , Mode: L , Size: (960, 750)
So the file is a bit weird - it's got a .tif extension, but it is actually a JPEG (as witness both by the Format value and the JFIF tag). But the Image class seems to handle it just fine anyway.

Is there a way I can turn on extra logging, or use the Python debugger to see what's going on in the recipe? I feel like if I could get to the point where it's failing and debug through it, I could figure out what's going on.
RobFreundlich is offline   Reply With Quote