Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/PIL/PcdImagePlugin.py: 29%
24 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# PCD file handling
6#
7# History:
8# 96-05-10 fl Created
9# 96-05-27 fl Added draft mode (128x192, 256x384)
10#
11# Copyright (c) Secret Labs AB 1997.
12# Copyright (c) Fredrik Lundh 1996.
13#
14# See the README file for information on usage and redistribution.
15#
18from . import Image, ImageFile
20##
21# Image plugin for PhotoCD images. This plugin only reads the 768x512
22# image from the file; higher resolutions are encoded in a proprietary
23# encoding.
26class PcdImageFile(ImageFile.ImageFile):
28 format = "PCD"
29 format_description = "Kodak PhotoCD"
31 def _open(self):
33 # rough
34 self.fp.seek(2048)
35 s = self.fp.read(2048)
37 if s[:4] != b"PCD_":
38 raise SyntaxError("not a PCD file")
40 orientation = s[1538] & 3
41 self.tile_post_rotate = None
42 if orientation == 1:
43 self.tile_post_rotate = 90
44 elif orientation == 3:
45 self.tile_post_rotate = -90
47 self.mode = "RGB"
48 self._size = 768, 512 # FIXME: not correct for rotated images!
49 self.tile = [("pcd", (0, 0) + self.size, 96 * 2048, None)]
51 def load_end(self):
52 if self.tile_post_rotate:
53 # Handle rotated PCDs
54 self.im = self.im.rotate(self.tile_post_rotate)
55 self._size = self.im.size
58#
59# registry
61Image.register_open(PcdImageFile.format, PcdImageFile)
63Image.register_extension(PcdImageFile.format, ".pcd")