MementoEmbed fails to generate a data URI if original resource favicons are corrupted
Closed this issue · 0 comments
shawnmjones commented
An exception is thrown if a favicon is corrupt and MementoEmbed attempts to convert it to a data URI:
Traceback (most recent call last):
File "/Volumes/nerfherder External/Unsynced-Projects/MementoEmbed/mementoembed/services/memento.py", line 67, in originaldata
originalresource.favicon, httpcache, 16, 16
File "/Volumes/nerfherder External/Unsynced-Projects/MementoEmbed/mementoembed/imageselection.py", line 35, in convert_imageuri_to_pngdata_uri
im = Image.open(ifp)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2577, in open
im = _open_core(fp, filename, prefix)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2567, in _open_core
im = factory(fp, filename)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/ImageFile.py", line 102, in __init__
self._open()
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 264, in _open
self.load()
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 267, in load
im = self.ico.getimage(self.size)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 150, in getimage
return self.frame(i)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/IcoImagePlugin.py", line 226, in frame
('1;I', int(w/8), -1) # 1bpp inverted, padded, reversed
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2403, in frombuffer
return frombytes(mode, size, data, decoder_name, args)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 2336, in frombytes
im.frombytes(data, decoder_name, args)
File "/Users/smj/.virtualenvs/MementoEmbed-gkunwTeo/lib/python3.7/site-packages/PIL/Image.py", line 788, in frombytes
raise ValueError("not enough image data")
Affected URI-Ms:
- https://wayback.archive-it.org/2535/20110409153347/http://www.dailyexpress.co.uk/posts/view/239488/11-killed-in-Brazil-school-shooting/
- http://wayback.archive-it.org/2823/20110909113011/http://www.theprovince.com/news/Russian+plane+crash+decimates+team+former+Canuck+Pavol+Demitra+roster/5364342/story.html