[ThumbnailCtrl] - small patch
massimo s.
devicerandom at gmail.com
Sat Nov 25 08:48:13 PST 2006
Hi,
I was trying Andrea Gavana's ThumbnailCtrl, and by playing with the demo
I found it blocks the generation of thumbnails if the PIL has troubles
reading the image (that is, thumbnails are only generated until the
corrupted/bad/whatever file is met).
I found that what I guess should be the correct behaviour (skipping the
troublesome image and continuing) can be restored by simply trapping the
exceptions in the LoadImages method:
def LoadImages(self, newfile, imagecount):
""" Methods That Load Images On ThumbnailCtrl. Used Internally. """
if not self._isrunning:
thread.exit()
return
try:
pil = Image.open(newfile)
originalsize = pil.size
pil.thumbnail((300, 240))
img = wx.EmptyImage(pil.size[0], pil.size[1])
img.SetData(pil.convert("RGB").tostring())
except:
pass
try:
self._items[imagecount]._threadedimage = img
self._items[imagecount]._originalsize = originalsize
self._items[imagecount]._bitmap = img
except:
return
(yes, I know it's not a real diff -c patch, but diff spits out garbage
on me, I don't know why - however the change is so trivial that
shouldn't require effort)
Is this harmless?
m.
More information about the wxpython-users
mailing list