mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Added _accept hook for XVThumbImagePlugin
This commit is contained in:
parent
90955e4953
commit
53de1ba049
|
@ -23,6 +23,8 @@ __version__ = "0.1"
|
|||
|
||||
o8 = _binary.o8
|
||||
|
||||
_MAGIC = b"P7 332"
|
||||
|
||||
# standard color palette for thumbnails (RGB332)
|
||||
PALETTE = b""
|
||||
for r in range(8):
|
||||
|
@ -30,6 +32,9 @@ for r in range(8):
|
|||
for b in range(4):
|
||||
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
||||
|
||||
def _accept(prefix):
|
||||
return prefix[:6] == _MAGIC
|
||||
|
||||
|
||||
##
|
||||
# Image plugin for XV thumbnail images.
|
||||
|
@ -42,8 +47,7 @@ class XVThumbImageFile(ImageFile.ImageFile):
|
|||
def _open(self):
|
||||
|
||||
# check magic
|
||||
s = self.fp.read(6)
|
||||
if s != b"P7 332":
|
||||
if self.fp.read(6) != _MAGIC:
|
||||
raise SyntaxError("not an XV thumbnail file")
|
||||
|
||||
# Skip to beginning of next line
|
||||
|
@ -72,4 +76,4 @@ class XVThumbImageFile(ImageFile.ImageFile):
|
|||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
Image.register_open(XVThumbImageFile.format, XVThumbImageFile)
|
||||
Image.register_open(XVThumbImageFile.format, XVThumbImageFile, _accept)
|
||||
|
|
Loading…
Reference in New Issue
Block a user