2
# The Python Imaging Library.
5
# Microsoft Image Composer support for PIL
8
# uses TiffImagePlugin.py to read the actual image streams
13
# Copyright (c) Secret Labs AB 1997.
14
# Copyright (c) Fredrik Lundh 1997.
16
# See the README file for information on usage and redistribution.
23
import Image, TiffImagePlugin
24
from OleFileIO import *
28
# --------------------------------------------------------------------
32
return prefix[:8] == MAGIC
35
# Image plugin for Microsoft's Image Composer file format.
37
class MicImageFile(TiffImagePlugin.TiffImageFile):
40
format_description = "Microsoft Image Composer"
44
# read the OLE directory and see if this is a likely
45
# to be a Microsoft Image Composer file
48
self.ole = OleFileIO(self.fp)
50
raise SyntaxError, "not an MIC file; invalid OLE file"
52
# find ACI subfiles with Image members (maybe not the
53
# best way to identify MIC files, but what the... ;-)
56
for file in self.ole.listdir():
57
if file[1:] and file[0][-4:] == ".ACI" and file[1] == "Image":
58
self.images.append(file)
60
# if we didn't find any images, this is probably not
63
raise SyntaxError, "not an MIC file; no image entries"
68
if len(self.images) > 1:
69
self.category = Image.CONTAINER
73
def seek(self, frame):
76
filename = self.images[frame]
78
raise EOFError, "no such frame"
80
self.fp = self.ole.openstream(filename)
82
TiffImagePlugin.TiffImageFile._open(self)
91
# --------------------------------------------------------------------
93
Image.register_open("MIC", MicImageFile, _accept)
95
Image.register_extension("MIC", ".mic")