Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MementoEmbed fails to generate a data URI if original resource favicons are corrupted #140

Closed
shawnmjones opened this issue Oct 22, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@shawnmjones
Copy link
Collaborator

commented Oct 22, 2018

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:

@shawnmjones shawnmjones added the bug label Oct 22, 2018

@shawnmjones shawnmjones self-assigned this Oct 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.