mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +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
|
o8 = _binary.o8
|
||||||
|
|
||||||
|
_MAGIC = b"P7 332"
|
||||||
|
|
||||||
# standard color palette for thumbnails (RGB332)
|
# standard color palette for thumbnails (RGB332)
|
||||||
PALETTE = b""
|
PALETTE = b""
|
||||||
for r in range(8):
|
for r in range(8):
|
||||||
|
@ -30,6 +32,9 @@ for r in range(8):
|
||||||
for b in range(4):
|
for b in range(4):
|
||||||
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
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.
|
# Image plugin for XV thumbnail images.
|
||||||
|
@ -42,8 +47,7 @@ class XVThumbImageFile(ImageFile.ImageFile):
|
||||||
def _open(self):
|
def _open(self):
|
||||||
|
|
||||||
# check magic
|
# check magic
|
||||||
s = self.fp.read(6)
|
if self.fp.read(6) != _MAGIC:
|
||||||
if s != b"P7 332":
|
|
||||||
raise SyntaxError("not an XV thumbnail file")
|
raise SyntaxError("not an XV thumbnail file")
|
||||||
|
|
||||||
# Skip to beginning of next line
|
# 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