@ai-ecoverse/py-pillow 12.3.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +30 -0
- package/README.md +4 -0
- package/lib/python3.14/site-packages/PIL/AvifImagePlugin.py +295 -0
- package/lib/python3.14/site-packages/PIL/BdfFontFile.py +124 -0
- package/lib/python3.14/site-packages/PIL/BlpImagePlugin.py +498 -0
- package/lib/python3.14/site-packages/PIL/BmpImagePlugin.py +514 -0
- package/lib/python3.14/site-packages/PIL/BufrStubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/ContainerIO.py +173 -0
- package/lib/python3.14/site-packages/PIL/CurImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/DcxImagePlugin.py +84 -0
- package/lib/python3.14/site-packages/PIL/DdsImagePlugin.py +632 -0
- package/lib/python3.14/site-packages/PIL/EpsImagePlugin.py +484 -0
- package/lib/python3.14/site-packages/PIL/ExifTags.py +384 -0
- package/lib/python3.14/site-packages/PIL/FitsImagePlugin.py +153 -0
- package/lib/python3.14/site-packages/PIL/FliImagePlugin.py +184 -0
- package/lib/python3.14/site-packages/PIL/FontFile.py +160 -0
- package/lib/python3.14/site-packages/PIL/FpxImagePlugin.py +262 -0
- package/lib/python3.14/site-packages/PIL/FtexImagePlugin.py +115 -0
- package/lib/python3.14/site-packages/PIL/GbrImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/GdImageFile.py +104 -0
- package/lib/python3.14/site-packages/PIL/GifImagePlugin.py +1223 -0
- package/lib/python3.14/site-packages/PIL/GimpGradientFile.py +154 -0
- package/lib/python3.14/site-packages/PIL/GimpPaletteFile.py +75 -0
- package/lib/python3.14/site-packages/PIL/GribStubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/Hdf5StubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/IcnsImagePlugin.py +401 -0
- package/lib/python3.14/site-packages/PIL/IcoImagePlugin.py +396 -0
- package/lib/python3.14/site-packages/PIL/ImImagePlugin.py +390 -0
- package/lib/python3.14/site-packages/PIL/Image.py +4385 -0
- package/lib/python3.14/site-packages/PIL/ImageChops.py +311 -0
- package/lib/python3.14/site-packages/PIL/ImageCms.py +1078 -0
- package/lib/python3.14/site-packages/PIL/ImageColor.py +320 -0
- package/lib/python3.14/site-packages/PIL/ImageDraw.py +1002 -0
- package/lib/python3.14/site-packages/PIL/ImageDraw2.py +244 -0
- package/lib/python3.14/site-packages/PIL/ImageEnhance.py +113 -0
- package/lib/python3.14/site-packages/PIL/ImageFile.py +938 -0
- package/lib/python3.14/site-packages/PIL/ImageFilter.py +617 -0
- package/lib/python3.14/site-packages/PIL/ImageFont.py +1330 -0
- package/lib/python3.14/site-packages/PIL/ImageGrab.py +234 -0
- package/lib/python3.14/site-packages/PIL/ImageMath.py +314 -0
- package/lib/python3.14/site-packages/PIL/ImageMode.py +85 -0
- package/lib/python3.14/site-packages/PIL/ImageMorph.py +317 -0
- package/lib/python3.14/site-packages/PIL/ImageOps.py +749 -0
- package/lib/python3.14/site-packages/PIL/ImagePalette.py +290 -0
- package/lib/python3.14/site-packages/PIL/ImagePath.py +20 -0
- package/lib/python3.14/site-packages/PIL/ImageQt.py +219 -0
- package/lib/python3.14/site-packages/PIL/ImageSequence.py +88 -0
- package/lib/python3.14/site-packages/PIL/ImageShow.py +367 -0
- package/lib/python3.14/site-packages/PIL/ImageStat.py +167 -0
- package/lib/python3.14/site-packages/PIL/ImageText.py +509 -0
- package/lib/python3.14/site-packages/PIL/ImageTk.py +266 -0
- package/lib/python3.14/site-packages/PIL/ImageTransform.py +136 -0
- package/lib/python3.14/site-packages/PIL/ImageWin.py +247 -0
- package/lib/python3.14/site-packages/PIL/ImtImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/IptcImagePlugin.py +226 -0
- package/lib/python3.14/site-packages/PIL/Jpeg2KImagePlugin.py +466 -0
- package/lib/python3.14/site-packages/PIL/JpegImagePlugin.py +889 -0
- package/lib/python3.14/site-packages/PIL/JpegPresets.py +242 -0
- package/lib/python3.14/site-packages/PIL/McIdasImagePlugin.py +78 -0
- package/lib/python3.14/site-packages/PIL/MicImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/MpegImagePlugin.py +84 -0
- package/lib/python3.14/site-packages/PIL/MpoImagePlugin.py +203 -0
- package/lib/python3.14/site-packages/PIL/MspImagePlugin.py +200 -0
- package/lib/python3.14/site-packages/PIL/PSDraw.py +238 -0
- package/lib/python3.14/site-packages/PIL/PaletteFile.py +54 -0
- package/lib/python3.14/site-packages/PIL/PalmImagePlugin.py +217 -0
- package/lib/python3.14/site-packages/PIL/PcdImagePlugin.py +68 -0
- package/lib/python3.14/site-packages/PIL/PcfFontFile.py +256 -0
- package/lib/python3.14/site-packages/PIL/PcxImagePlugin.py +232 -0
- package/lib/python3.14/site-packages/PIL/PdfImagePlugin.py +315 -0
- package/lib/python3.14/site-packages/PIL/PdfParser.py +1092 -0
- package/lib/python3.14/site-packages/PIL/PixarImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/PngImagePlugin.py +1578 -0
- package/lib/python3.14/site-packages/PIL/PpmImagePlugin.py +375 -0
- package/lib/python3.14/site-packages/PIL/PsdImagePlugin.py +339 -0
- package/lib/python3.14/site-packages/PIL/QoiImagePlugin.py +235 -0
- package/lib/python3.14/site-packages/PIL/SgiImagePlugin.py +231 -0
- package/lib/python3.14/site-packages/PIL/SpiderImagePlugin.py +332 -0
- package/lib/python3.14/site-packages/PIL/SunImagePlugin.py +145 -0
- package/lib/python3.14/site-packages/PIL/TarIO.py +61 -0
- package/lib/python3.14/site-packages/PIL/TgaImagePlugin.py +284 -0
- package/lib/python3.14/site-packages/PIL/TiffImagePlugin.py +2354 -0
- package/lib/python3.14/site-packages/PIL/TiffTags.py +566 -0
- package/lib/python3.14/site-packages/PIL/WalImageFile.py +129 -0
- package/lib/python3.14/site-packages/PIL/WebPImagePlugin.py +322 -0
- package/lib/python3.14/site-packages/PIL/WmfImagePlugin.py +183 -0
- package/lib/python3.14/site-packages/PIL/XVThumbImagePlugin.py +83 -0
- package/lib/python3.14/site-packages/PIL/XbmImagePlugin.py +98 -0
- package/lib/python3.14/site-packages/PIL/XpmImagePlugin.py +157 -0
- package/lib/python3.14/site-packages/PIL/__init__.py +87 -0
- package/lib/python3.14/site-packages/PIL/__main__.py +7 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/AvifImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BdfFontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BmpImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BufrStubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ContainerIO.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/CurImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/DcxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/DdsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/EpsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ExifTags.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FitsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FliImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FpxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FtexImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GbrImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GdImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GifImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GimpGradientFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GimpPaletteFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GribStubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Hdf5StubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IcnsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IcoImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Image.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageChops.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageCms.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageColor.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw2.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageEnhance.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFilter.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFont.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageGrab.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMath.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMode.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMorph.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageOps.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImagePalette.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImagePath.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageQt.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageSequence.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageShow.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageStat.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageText.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageTk.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageTransform.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageWin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImtImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IptcImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Jpeg2KImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/JpegImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/JpegPresets.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/McIdasImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MicImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MpegImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MpoImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MspImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PSDraw.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PaletteFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PalmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcdImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcfFontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PdfImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PdfParser.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PixarImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PngImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PpmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PsdImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/QoiImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SgiImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SpiderImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SunImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TarIO.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TgaImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TiffImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TiffTags.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WalImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WebPImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WmfImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XVThumbImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XbmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XpmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/__init__.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/__main__.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_binary.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_deprecate.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_tkinter_finder.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_typing.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_util.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_version.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/features.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/report.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/_avif.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_binary.py +113 -0
- package/lib/python3.14/site-packages/PIL/_deprecate.py +72 -0
- package/lib/python3.14/site-packages/PIL/_imaging.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imaging.pyi +31 -0
- package/lib/python3.14/site-packages/PIL/_imagingcms.pyi +143 -0
- package/lib/python3.14/site-packages/PIL/_imagingft.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingft.pyi +70 -0
- package/lib/python3.14/site-packages/PIL/_imagingmath.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingmath.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_imagingmorph.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingmorph.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_imagingtk.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingtk.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_tkinter_finder.py +20 -0
- package/lib/python3.14/site-packages/PIL/_typing.py +45 -0
- package/lib/python3.14/site-packages/PIL/_util.py +29 -0
- package/lib/python3.14/site-packages/PIL/_version.py +4 -0
- package/lib/python3.14/site-packages/PIL/_webp.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/features.py +343 -0
- package/lib/python3.14/site-packages/PIL/py.typed +0 -0
- package/lib/python3.14/site-packages/PIL/report.py +5 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/METADATA +180 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/RECORD +117 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/WHEEL +5 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/licenses/LICENSE +30 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/top_level.txt +1 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/zip-safe +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# XPM File handling
|
|
6
|
+
#
|
|
7
|
+
# History:
|
|
8
|
+
# 1996-12-29 fl Created
|
|
9
|
+
# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.7)
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) Secret Labs AB 1997-2001.
|
|
12
|
+
# Copyright (c) Fredrik Lundh 1996-2001.
|
|
13
|
+
#
|
|
14
|
+
# See the README file for information on usage and redistribution.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
from . import Image, ImageFile, ImagePalette
|
|
21
|
+
from ._binary import o8
|
|
22
|
+
|
|
23
|
+
# XPM header
|
|
24
|
+
xpm_head = re.compile(b'"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)')
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _accept(prefix: bytes) -> bool:
|
|
28
|
+
return prefix.startswith(b"/* XPM */")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Image plugin for X11 pixel maps.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class XpmImageFile(ImageFile.ImageFile):
|
|
36
|
+
format = "XPM"
|
|
37
|
+
format_description = "X11 Pixel Map"
|
|
38
|
+
|
|
39
|
+
def _open(self) -> None:
|
|
40
|
+
assert self.fp is not None
|
|
41
|
+
if not _accept(self.fp.read(9)):
|
|
42
|
+
msg = "not an XPM file"
|
|
43
|
+
raise SyntaxError(msg)
|
|
44
|
+
|
|
45
|
+
# skip forward to next string
|
|
46
|
+
while True:
|
|
47
|
+
line = self.fp.readline()
|
|
48
|
+
if not line:
|
|
49
|
+
msg = "broken XPM file"
|
|
50
|
+
raise SyntaxError(msg)
|
|
51
|
+
m = xpm_head.match(line)
|
|
52
|
+
if m:
|
|
53
|
+
break
|
|
54
|
+
|
|
55
|
+
self._size = int(m.group(1)), int(m.group(2))
|
|
56
|
+
|
|
57
|
+
palette_length = int(m.group(3))
|
|
58
|
+
bpp = int(m.group(4))
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
# load palette description
|
|
62
|
+
|
|
63
|
+
palette = {}
|
|
64
|
+
|
|
65
|
+
for _ in range(palette_length):
|
|
66
|
+
line = self.fp.readline().rstrip()
|
|
67
|
+
|
|
68
|
+
c = line[1 : bpp + 1]
|
|
69
|
+
s = line[bpp + 1 : -2].split()
|
|
70
|
+
|
|
71
|
+
for i in range(0, len(s), 2):
|
|
72
|
+
if s[i] == b"c":
|
|
73
|
+
# process colour key
|
|
74
|
+
rgb = s[i + 1]
|
|
75
|
+
if rgb == b"None":
|
|
76
|
+
self.info["transparency"] = c
|
|
77
|
+
elif rgb.startswith(b"#"):
|
|
78
|
+
rgb_int = int(rgb[1:], 16)
|
|
79
|
+
palette[c] = (
|
|
80
|
+
o8((rgb_int >> 16) & 255)
|
|
81
|
+
+ o8((rgb_int >> 8) & 255)
|
|
82
|
+
+ o8(rgb_int & 255)
|
|
83
|
+
)
|
|
84
|
+
else:
|
|
85
|
+
# unknown colour
|
|
86
|
+
msg = "cannot read this XPM file"
|
|
87
|
+
raise ValueError(msg)
|
|
88
|
+
break
|
|
89
|
+
|
|
90
|
+
else:
|
|
91
|
+
# missing colour key
|
|
92
|
+
msg = "cannot read this XPM file"
|
|
93
|
+
raise ValueError(msg)
|
|
94
|
+
|
|
95
|
+
args: tuple[int, dict[bytes, bytes] | tuple[bytes, ...]]
|
|
96
|
+
if palette_length > 256:
|
|
97
|
+
self._mode = "RGB"
|
|
98
|
+
args = (bpp, palette)
|
|
99
|
+
else:
|
|
100
|
+
self._mode = "P"
|
|
101
|
+
self.palette = ImagePalette.raw("RGB", b"".join(palette.values()))
|
|
102
|
+
args = (bpp, tuple(palette.keys()))
|
|
103
|
+
|
|
104
|
+
self.tile = [ImageFile._Tile("xpm", (0, 0) + self.size, self.fp.tell(), args)]
|
|
105
|
+
|
|
106
|
+
def load_read(self, read_bytes: int) -> bytes:
|
|
107
|
+
#
|
|
108
|
+
# load all image data in one chunk
|
|
109
|
+
|
|
110
|
+
xsize, ysize = self.size
|
|
111
|
+
|
|
112
|
+
assert self.fp is not None
|
|
113
|
+
s = [self.fp.readline()[1 : xsize + 1].ljust(xsize) for i in range(ysize)]
|
|
114
|
+
|
|
115
|
+
return b"".join(s)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class XpmDecoder(ImageFile.PyDecoder):
|
|
119
|
+
_pulls_fd = True
|
|
120
|
+
|
|
121
|
+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
|
|
122
|
+
assert self.fd is not None
|
|
123
|
+
|
|
124
|
+
data = bytearray()
|
|
125
|
+
bpp, palette = self.args
|
|
126
|
+
dest_length = self.state.xsize * self.state.ysize
|
|
127
|
+
if self.mode == "RGB":
|
|
128
|
+
dest_length *= 3
|
|
129
|
+
pixel_header = False
|
|
130
|
+
while len(data) < dest_length:
|
|
131
|
+
line = self.fd.readline()
|
|
132
|
+
if not line:
|
|
133
|
+
break
|
|
134
|
+
if line.rstrip() == b"/* pixels */" and not pixel_header:
|
|
135
|
+
pixel_header = True
|
|
136
|
+
continue
|
|
137
|
+
line = b'"'.join(line.split(b'"')[1:-1])
|
|
138
|
+
for i in range(0, len(line), bpp):
|
|
139
|
+
key = line[i : i + bpp]
|
|
140
|
+
if self.mode == "RGB":
|
|
141
|
+
data += palette[key]
|
|
142
|
+
else:
|
|
143
|
+
data += o8(palette.index(key))
|
|
144
|
+
self.set_as_raw(bytes(data))
|
|
145
|
+
return -1, 0
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
#
|
|
149
|
+
# Registry
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Image.register_open(XpmImageFile.format, XpmImageFile, _accept)
|
|
153
|
+
Image.register_decoder("xpm", XpmDecoder)
|
|
154
|
+
|
|
155
|
+
Image.register_extension(XpmImageFile.format, ".xpm")
|
|
156
|
+
|
|
157
|
+
Image.register_mime(XpmImageFile.format, "image/xpm")
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Pillow (Fork of the Python Imaging Library)
|
|
2
|
+
|
|
3
|
+
Pillow is the friendly PIL fork by Jeffrey 'Alex' Clark and contributors.
|
|
4
|
+
https://github.com/python-pillow/Pillow/
|
|
5
|
+
|
|
6
|
+
Pillow is forked from PIL 1.1.7.
|
|
7
|
+
|
|
8
|
+
PIL is the Python Imaging Library by Fredrik Lundh and contributors.
|
|
9
|
+
Copyright (c) 1999 by Secret Labs AB.
|
|
10
|
+
|
|
11
|
+
Use PIL.__version__ for this Pillow version.
|
|
12
|
+
|
|
13
|
+
;-)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from . import _version
|
|
19
|
+
|
|
20
|
+
# VERSION was removed in Pillow 6.0.0.
|
|
21
|
+
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
|
22
|
+
# Use __version__ instead.
|
|
23
|
+
__version__ = _version.__version__
|
|
24
|
+
del _version
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
_plugins = [
|
|
28
|
+
"AvifImagePlugin",
|
|
29
|
+
"BlpImagePlugin",
|
|
30
|
+
"BmpImagePlugin",
|
|
31
|
+
"BufrStubImagePlugin",
|
|
32
|
+
"CurImagePlugin",
|
|
33
|
+
"DcxImagePlugin",
|
|
34
|
+
"DdsImagePlugin",
|
|
35
|
+
"EpsImagePlugin",
|
|
36
|
+
"FitsImagePlugin",
|
|
37
|
+
"FliImagePlugin",
|
|
38
|
+
"FpxImagePlugin",
|
|
39
|
+
"FtexImagePlugin",
|
|
40
|
+
"GbrImagePlugin",
|
|
41
|
+
"GifImagePlugin",
|
|
42
|
+
"GribStubImagePlugin",
|
|
43
|
+
"Hdf5StubImagePlugin",
|
|
44
|
+
"IcnsImagePlugin",
|
|
45
|
+
"IcoImagePlugin",
|
|
46
|
+
"ImImagePlugin",
|
|
47
|
+
"ImtImagePlugin",
|
|
48
|
+
"IptcImagePlugin",
|
|
49
|
+
"JpegImagePlugin",
|
|
50
|
+
"Jpeg2KImagePlugin",
|
|
51
|
+
"McIdasImagePlugin",
|
|
52
|
+
"MicImagePlugin",
|
|
53
|
+
"MpegImagePlugin",
|
|
54
|
+
"MpoImagePlugin",
|
|
55
|
+
"MspImagePlugin",
|
|
56
|
+
"PalmImagePlugin",
|
|
57
|
+
"PcdImagePlugin",
|
|
58
|
+
"PcxImagePlugin",
|
|
59
|
+
"PdfImagePlugin",
|
|
60
|
+
"PixarImagePlugin",
|
|
61
|
+
"PngImagePlugin",
|
|
62
|
+
"PpmImagePlugin",
|
|
63
|
+
"PsdImagePlugin",
|
|
64
|
+
"QoiImagePlugin",
|
|
65
|
+
"SgiImagePlugin",
|
|
66
|
+
"SpiderImagePlugin",
|
|
67
|
+
"SunImagePlugin",
|
|
68
|
+
"TgaImagePlugin",
|
|
69
|
+
"TiffImagePlugin",
|
|
70
|
+
"WebPImagePlugin",
|
|
71
|
+
"WmfImagePlugin",
|
|
72
|
+
"XbmImagePlugin",
|
|
73
|
+
"XpmImagePlugin",
|
|
74
|
+
"XVThumbImagePlugin",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class UnidentifiedImageError(OSError):
|
|
79
|
+
"""
|
|
80
|
+
Raised in :py:meth:`PIL.Image.open` if an image cannot be opened and identified.
|
|
81
|
+
|
|
82
|
+
If a PNG image raises this error, setting :data:`.ImageFile.LOAD_TRUNCATED_IMAGES`
|
|
83
|
+
to true may allow the image to be opened after all. The setting will ignore missing
|
|
84
|
+
data and checksum failures.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
pass
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# Binary input/output support routines.
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 1997-2003 by Secret Labs AB
|
|
8
|
+
# Copyright (c) 1995-2003 by Fredrik Lundh
|
|
9
|
+
# Copyright (c) 2012 by Brian Crowell
|
|
10
|
+
#
|
|
11
|
+
# See the README file for information on usage and redistribution.
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
"""Binary input/output support routines."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from struct import pack, unpack_from
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def i8(c: bytes) -> int:
|
|
23
|
+
return c[0]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def o8(i: int) -> bytes:
|
|
27
|
+
return bytes((i & 255,))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Input, le = little endian, be = big endian
|
|
31
|
+
def i16le(c: bytes, o: int = 0) -> int:
|
|
32
|
+
"""
|
|
33
|
+
Converts a 2-bytes (16 bits) string to an unsigned integer.
|
|
34
|
+
|
|
35
|
+
:param c: string containing bytes to convert
|
|
36
|
+
:param o: offset of bytes to convert in string
|
|
37
|
+
"""
|
|
38
|
+
return unpack_from("<H", c, o)[0]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def si16le(c: bytes, o: int = 0) -> int:
|
|
42
|
+
"""
|
|
43
|
+
Converts a 2-bytes (16 bits) string to a signed integer.
|
|
44
|
+
|
|
45
|
+
:param c: string containing bytes to convert
|
|
46
|
+
:param o: offset of bytes to convert in string
|
|
47
|
+
"""
|
|
48
|
+
return unpack_from("<h", c, o)[0]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def si16be(c: bytes, o: int = 0) -> int:
|
|
52
|
+
"""
|
|
53
|
+
Converts a 2-bytes (16 bits) string to a signed integer, big endian.
|
|
54
|
+
|
|
55
|
+
:param c: string containing bytes to convert
|
|
56
|
+
:param o: offset of bytes to convert in string
|
|
57
|
+
"""
|
|
58
|
+
return unpack_from(">h", c, o)[0]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def i32le(c: bytes, o: int = 0) -> int:
|
|
62
|
+
"""
|
|
63
|
+
Converts a 4-bytes (32 bits) string to an unsigned integer.
|
|
64
|
+
|
|
65
|
+
:param c: string containing bytes to convert
|
|
66
|
+
:param o: offset of bytes to convert in string
|
|
67
|
+
"""
|
|
68
|
+
return unpack_from("<I", c, o)[0]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def si32le(c: bytes, o: int = 0) -> int:
|
|
72
|
+
"""
|
|
73
|
+
Converts a 4-bytes (32 bits) string to a signed integer.
|
|
74
|
+
|
|
75
|
+
:param c: string containing bytes to convert
|
|
76
|
+
:param o: offset of bytes to convert in string
|
|
77
|
+
"""
|
|
78
|
+
return unpack_from("<i", c, o)[0]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def si32be(c: bytes, o: int = 0) -> int:
|
|
82
|
+
"""
|
|
83
|
+
Converts a 4-bytes (32 bits) string to a signed integer, big endian.
|
|
84
|
+
|
|
85
|
+
:param c: string containing bytes to convert
|
|
86
|
+
:param o: offset of bytes to convert in string
|
|
87
|
+
"""
|
|
88
|
+
return unpack_from(">i", c, o)[0]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def i16be(c: bytes, o: int = 0) -> int:
|
|
92
|
+
return unpack_from(">H", c, o)[0]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def i32be(c: bytes, o: int = 0) -> int:
|
|
96
|
+
return unpack_from(">I", c, o)[0]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# Output, le = little endian, be = big endian
|
|
100
|
+
def o16le(i: int) -> bytes:
|
|
101
|
+
return pack("<H", i)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def o32le(i: int) -> bytes:
|
|
105
|
+
return pack("<I", i)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def o16be(i: int) -> bytes:
|
|
109
|
+
return pack(">H", i)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def o32be(i: int) -> bytes:
|
|
113
|
+
return pack(">I", i)
|