Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/PIL/PixarImagePlugin.py: 48%
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
23from . import Image, ImageFile
24from ._binary import i16le as i16
26#
27# helpers
30def _accept(prefix: bytes) -> bool:
31 return prefix.startswith(b"\200\350\000\000")
34##
35# Image plugin for PIXAR raster images.
38class PixarImageFile(ImageFile.ImageFile):
39 format = "PIXAR"
40 format_description = "PIXAR raster image"
42 def _open(self) -> None:
43 # assuming a 4-byte magic label
44 assert self.fp is not None
46 s = self.fp.read(4)
47 if not _accept(s):
48 msg = "not a PIXAR file"
49 raise SyntaxError(msg)
51 # read rest of header
52 s = s + self.fp.read(508)
54 self._size = i16(s, 418), i16(s, 416)
56 # get channel/depth descriptions
57 mode = i16(s, 424), i16(s, 426)
59 if mode == (14, 2):
60 self._mode = "RGB"
61 # FIXME: to be continued...
63 # create tile descriptor (assuming "dumped")
64 self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 1024, self.mode)]
67#
68# --------------------------------------------------------------------
70Image.register_open(PixarImageFile.format, PixarImageFile, _accept)
72Image.register_extension(PixarImageFile.format, ".pxr")