Pillow/src/PIL/PixarImagePlugin.py

71 lines
1.6 KiB
Python
Raw Normal View History

2010-07-31 06:52:47 +04:00
#
# The Python Imaging Library.
# $Id$
#
# PIXAR raster support for PIL
#
# history:
# 97-01-29 fl Created
#
# notes:
# This is incomplete; it is based on a few samples created with
# Photoshop 2.5 and 3.0, and a summary description provided by
# Greg Coats <gcoats@labiris.er.usgs.gov>. Hopefully, "L" and
# "RGBA" support will be added in future versions.
#
# Copyright (c) Secret Labs AB 1997.
# Copyright (c) Fredrik Lundh 1997.
#
# See the README file for information on usage and redistribution.
#
from . import Image, ImageFile
from ._binary import i16le as i16
2010-07-31 06:52:47 +04:00
#
# helpers
2019-03-21 16:28:20 +03:00
def _accept(prefix):
return prefix[:4] == b"\200\350\000\000"
2010-07-31 06:52:47 +04:00
##
# Image plugin for PIXAR raster images.
2019-03-21 16:28:20 +03:00
2010-07-31 06:52:47 +04:00
class PixarImageFile(ImageFile.ImageFile):
format = "PIXAR"
format_description = "PIXAR raster image"
def _open(self):
# assuming a 4-byte magic label
2010-07-31 06:52:47 +04:00
s = self.fp.read(4)
if not _accept(s):
raise SyntaxError("not a PIXAR file")
2010-07-31 06:52:47 +04:00
# read rest of header
s = s + self.fp.read(508)
self._size = i16(s, 418), i16(s, 416)
2010-07-31 06:52:47 +04:00
# get channel/depth descriptions
mode = i16(s, 424), i16(s, 426)
2010-07-31 06:52:47 +04:00
if mode == (14, 2):
self.mode = "RGB"
# FIXME: to be continued...
# create tile descriptor (assuming "dumped")
2019-03-21 16:28:20 +03:00
self.tile = [("raw", (0, 0) + self.size, 1024, (self.mode, 0, 1))]
2010-07-31 06:52:47 +04:00
2017-02-28 09:27:53 +03:00
2010-07-31 06:52:47 +04:00
#
# --------------------------------------------------------------------
Image.register_open(PixarImageFile.format, PixarImageFile, _accept)
2010-07-31 06:52:47 +04:00
2016-04-05 16:01:39 +03:00
Image.register_extension(PixarImageFile.format, ".pxr")