Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/PIL/PixarImagePlugin.py: 50%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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#
21from __future__ import annotations
23__lazy_modules__ = {"PIL._binary"}
25from . import Image, ImageFile
26from ._binary import i16le as i16
28#
29# helpers
32def _accept(prefix: bytes) -> bool:
33 return prefix.startswith(b"\200\350\000\000")
36##
37# Image plugin for PIXAR raster images.
40class PixarImageFile(ImageFile.ImageFile):
41 format = "PIXAR"
42 format_description = "PIXAR raster image"
44 def _open(self) -> None:
45 # assuming a 4-byte magic label
46 assert self.fp is not None
48 s = self.fp.read(4)
49 if not _accept(s):
50 msg = "not a PIXAR file"
51 raise SyntaxError(msg)
53 # read rest of header
54 s = s + self.fp.read(508)
56 self._size = i16(s, 418), i16(s, 416)
58 # get channel/depth descriptions
59 mode = i16(s, 424), i16(s, 426)
61 if mode == (14, 2):
62 self._mode = "RGB"
63 # FIXME: to be continued...
65 # create tile descriptor (assuming "dumped")
66 self.tile = [ImageFile._Tile("raw", None, 1024, self.mode)]
69#
70# --------------------------------------------------------------------
72Image.register_open(PixarImageFile.format, PixarImageFile, _accept)
74Image.register_extension(PixarImageFile.format, ".pxr")