From 53197808f5e5b8a78570ea2221f91684e0553259 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 19 Apr 2016 20:59:32 +1000 Subject: [PATCH] Added _accept hook for PixarImagePlugin --- PIL/PixarImagePlugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PIL/PixarImagePlugin.py b/PIL/PixarImagePlugin.py index 783462a9a..fd002d9cf 100644 --- a/PIL/PixarImagePlugin.py +++ b/PIL/PixarImagePlugin.py @@ -29,6 +29,10 @@ __version__ = "0.1" i16 = _binary.i16le +def _accept(prefix): + return prefix[:4] == b"\200\350\000\000" + + ## # Image plugin for PIXAR raster images. @@ -39,7 +43,7 @@ class PixarImageFile(ImageFile.ImageFile): def _open(self): - # assuming a 4-byte magic label (FIXME: add "_accept" hook) + # assuming a 4-byte magic label s = self.fp.read(4) if s != b"\200\350\000\000": raise SyntaxError("not a PIXAR file") @@ -62,6 +66,6 @@ class PixarImageFile(ImageFile.ImageFile): # # -------------------------------------------------------------------- -Image.register_open(PixarImageFile.format, PixarImageFile) +Image.register_open(PixarImageFile.format, PixarImageFile, _accept) Image.register_extension(PixarImageFile.format, ".pxr")