## The Python Imaging Library.# $Id$## Microsoft Image Composer support for PIL## Notes:# uses TiffImagePlugin.py to read the actual image streams## History:# 97-01-20 fl Created## Copyright (c) Secret Labs AB 1997.# Copyright (c) Fredrik Lundh 1997.## See the README file for information on usage and redistribution.#from__future__importannotationsimportolefilefrom.importImage,TiffImagePlugin## --------------------------------------------------------------------def_accept(prefix:bytes)->bool:returnprefix.startswith(olefile.MAGIC)### Image plugin for Microsoft's Image Composer file format.
[docs]classMicImageFile(TiffImagePlugin.TiffImageFile):format="MIC"format_description="Microsoft Image Composer"_close_exclusive_fp_after_loading=Falsedef_open(self)->None:# read the OLE directory and see if this is a likely# to be a Microsoft Image Composer filetry:self.ole=olefile.OleFileIO(self.fp)exceptOSErrorase:msg="not an MIC file; invalid OLE file"raiseSyntaxError(msg)frome# find ACI subfiles with Image members (maybe not the# best way to identify MIC files, but what the... ;-)self.images=[pathforpathinself.ole.listdir()ifpath[1:]andpath[0].endswith(".ACI")andpath[1]=="Image"]# if we didn't find any images, this is probably not# an MIC file.ifnotself.images:msg="not an MIC file; no image entries"raiseSyntaxError(msg)self.frame=-1self._n_frames=len(self.images)self.is_animated=self._n_frames>1self.__fp=self.fpself.seek(0)