Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/PIL/PixarImagePlugin.py: 44%
19 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1#
2# The Python Imaging Library.
3# $Id$
4#
5# PIXAR raster support for PIL
6#
7# history:
8# 97-01-29 fl Created
9#
10# notes:
11# This is incomplete; it is based on a few samples created with
12# Photoshop 2.5 and 3.0, and a summary description provided by
13# Greg Coats <gcoats@labiris.er.usgs.gov>. Hopefully, "L" and
14# "RGBA" support will be added in future versions.
15#
16# Copyright (c) Secret Labs AB 1997.
17# Copyright (c) Fredrik Lundh 1997.
18#
19# See the README file for information on usage and redistribution.
20#
22from . import Image, ImageFile
23from ._binary import i16le as i16
25#
26# helpers
29def _accept(prefix):
30 return prefix[:4] == b"\200\350\000\000"
33##
34# Image plugin for PIXAR raster images.
37class PixarImageFile(ImageFile.ImageFile):
39 format = "PIXAR"
40 format_description = "PIXAR raster image"
42 def _open(self):
44 # assuming a 4-byte magic label
45 s = self.fp.read(4)
46 if not _accept(s):
47 raise SyntaxError("not a PIXAR file")
49 # read rest of header
50 s = s + self.fp.read(508)
52 self._size = i16(s, 418), i16(s, 416)
54 # get channel/depth descriptions
55 mode = i16(s, 424), i16(s, 426)
57 if mode == (14, 2):
58 self.mode = "RGB"
59 # FIXME: to be continued...
61 # create tile descriptor (assuming "dumped")
62 self.tile = [("raw", (0, 0) + self.size, 1024, (self.mode, 0, 1))]
65#
66# --------------------------------------------------------------------
68Image.register_open(PixarImageFile.format, PixarImageFile, _accept)
70Image.register_extension(PixarImageFile.format, ".pxr")