@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.
Files changed (217) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +4 -0
  3. package/lib/python3.14/site-packages/PIL/AvifImagePlugin.py +295 -0
  4. package/lib/python3.14/site-packages/PIL/BdfFontFile.py +124 -0
  5. package/lib/python3.14/site-packages/PIL/BlpImagePlugin.py +498 -0
  6. package/lib/python3.14/site-packages/PIL/BmpImagePlugin.py +514 -0
  7. package/lib/python3.14/site-packages/PIL/BufrStubImagePlugin.py +72 -0
  8. package/lib/python3.14/site-packages/PIL/ContainerIO.py +173 -0
  9. package/lib/python3.14/site-packages/PIL/CurImagePlugin.py +103 -0
  10. package/lib/python3.14/site-packages/PIL/DcxImagePlugin.py +84 -0
  11. package/lib/python3.14/site-packages/PIL/DdsImagePlugin.py +632 -0
  12. package/lib/python3.14/site-packages/PIL/EpsImagePlugin.py +484 -0
  13. package/lib/python3.14/site-packages/PIL/ExifTags.py +384 -0
  14. package/lib/python3.14/site-packages/PIL/FitsImagePlugin.py +153 -0
  15. package/lib/python3.14/site-packages/PIL/FliImagePlugin.py +184 -0
  16. package/lib/python3.14/site-packages/PIL/FontFile.py +160 -0
  17. package/lib/python3.14/site-packages/PIL/FpxImagePlugin.py +262 -0
  18. package/lib/python3.14/site-packages/PIL/FtexImagePlugin.py +115 -0
  19. package/lib/python3.14/site-packages/PIL/GbrImagePlugin.py +103 -0
  20. package/lib/python3.14/site-packages/PIL/GdImageFile.py +104 -0
  21. package/lib/python3.14/site-packages/PIL/GifImagePlugin.py +1223 -0
  22. package/lib/python3.14/site-packages/PIL/GimpGradientFile.py +154 -0
  23. package/lib/python3.14/site-packages/PIL/GimpPaletteFile.py +75 -0
  24. package/lib/python3.14/site-packages/PIL/GribStubImagePlugin.py +72 -0
  25. package/lib/python3.14/site-packages/PIL/Hdf5StubImagePlugin.py +72 -0
  26. package/lib/python3.14/site-packages/PIL/IcnsImagePlugin.py +401 -0
  27. package/lib/python3.14/site-packages/PIL/IcoImagePlugin.py +396 -0
  28. package/lib/python3.14/site-packages/PIL/ImImagePlugin.py +390 -0
  29. package/lib/python3.14/site-packages/PIL/Image.py +4385 -0
  30. package/lib/python3.14/site-packages/PIL/ImageChops.py +311 -0
  31. package/lib/python3.14/site-packages/PIL/ImageCms.py +1078 -0
  32. package/lib/python3.14/site-packages/PIL/ImageColor.py +320 -0
  33. package/lib/python3.14/site-packages/PIL/ImageDraw.py +1002 -0
  34. package/lib/python3.14/site-packages/PIL/ImageDraw2.py +244 -0
  35. package/lib/python3.14/site-packages/PIL/ImageEnhance.py +113 -0
  36. package/lib/python3.14/site-packages/PIL/ImageFile.py +938 -0
  37. package/lib/python3.14/site-packages/PIL/ImageFilter.py +617 -0
  38. package/lib/python3.14/site-packages/PIL/ImageFont.py +1330 -0
  39. package/lib/python3.14/site-packages/PIL/ImageGrab.py +234 -0
  40. package/lib/python3.14/site-packages/PIL/ImageMath.py +314 -0
  41. package/lib/python3.14/site-packages/PIL/ImageMode.py +85 -0
  42. package/lib/python3.14/site-packages/PIL/ImageMorph.py +317 -0
  43. package/lib/python3.14/site-packages/PIL/ImageOps.py +749 -0
  44. package/lib/python3.14/site-packages/PIL/ImagePalette.py +290 -0
  45. package/lib/python3.14/site-packages/PIL/ImagePath.py +20 -0
  46. package/lib/python3.14/site-packages/PIL/ImageQt.py +219 -0
  47. package/lib/python3.14/site-packages/PIL/ImageSequence.py +88 -0
  48. package/lib/python3.14/site-packages/PIL/ImageShow.py +367 -0
  49. package/lib/python3.14/site-packages/PIL/ImageStat.py +167 -0
  50. package/lib/python3.14/site-packages/PIL/ImageText.py +509 -0
  51. package/lib/python3.14/site-packages/PIL/ImageTk.py +266 -0
  52. package/lib/python3.14/site-packages/PIL/ImageTransform.py +136 -0
  53. package/lib/python3.14/site-packages/PIL/ImageWin.py +247 -0
  54. package/lib/python3.14/site-packages/PIL/ImtImagePlugin.py +103 -0
  55. package/lib/python3.14/site-packages/PIL/IptcImagePlugin.py +226 -0
  56. package/lib/python3.14/site-packages/PIL/Jpeg2KImagePlugin.py +466 -0
  57. package/lib/python3.14/site-packages/PIL/JpegImagePlugin.py +889 -0
  58. package/lib/python3.14/site-packages/PIL/JpegPresets.py +242 -0
  59. package/lib/python3.14/site-packages/PIL/McIdasImagePlugin.py +78 -0
  60. package/lib/python3.14/site-packages/PIL/MicImagePlugin.py +103 -0
  61. package/lib/python3.14/site-packages/PIL/MpegImagePlugin.py +84 -0
  62. package/lib/python3.14/site-packages/PIL/MpoImagePlugin.py +203 -0
  63. package/lib/python3.14/site-packages/PIL/MspImagePlugin.py +200 -0
  64. package/lib/python3.14/site-packages/PIL/PSDraw.py +238 -0
  65. package/lib/python3.14/site-packages/PIL/PaletteFile.py +54 -0
  66. package/lib/python3.14/site-packages/PIL/PalmImagePlugin.py +217 -0
  67. package/lib/python3.14/site-packages/PIL/PcdImagePlugin.py +68 -0
  68. package/lib/python3.14/site-packages/PIL/PcfFontFile.py +256 -0
  69. package/lib/python3.14/site-packages/PIL/PcxImagePlugin.py +232 -0
  70. package/lib/python3.14/site-packages/PIL/PdfImagePlugin.py +315 -0
  71. package/lib/python3.14/site-packages/PIL/PdfParser.py +1092 -0
  72. package/lib/python3.14/site-packages/PIL/PixarImagePlugin.py +72 -0
  73. package/lib/python3.14/site-packages/PIL/PngImagePlugin.py +1578 -0
  74. package/lib/python3.14/site-packages/PIL/PpmImagePlugin.py +375 -0
  75. package/lib/python3.14/site-packages/PIL/PsdImagePlugin.py +339 -0
  76. package/lib/python3.14/site-packages/PIL/QoiImagePlugin.py +235 -0
  77. package/lib/python3.14/site-packages/PIL/SgiImagePlugin.py +231 -0
  78. package/lib/python3.14/site-packages/PIL/SpiderImagePlugin.py +332 -0
  79. package/lib/python3.14/site-packages/PIL/SunImagePlugin.py +145 -0
  80. package/lib/python3.14/site-packages/PIL/TarIO.py +61 -0
  81. package/lib/python3.14/site-packages/PIL/TgaImagePlugin.py +284 -0
  82. package/lib/python3.14/site-packages/PIL/TiffImagePlugin.py +2354 -0
  83. package/lib/python3.14/site-packages/PIL/TiffTags.py +566 -0
  84. package/lib/python3.14/site-packages/PIL/WalImageFile.py +129 -0
  85. package/lib/python3.14/site-packages/PIL/WebPImagePlugin.py +322 -0
  86. package/lib/python3.14/site-packages/PIL/WmfImagePlugin.py +183 -0
  87. package/lib/python3.14/site-packages/PIL/XVThumbImagePlugin.py +83 -0
  88. package/lib/python3.14/site-packages/PIL/XbmImagePlugin.py +98 -0
  89. package/lib/python3.14/site-packages/PIL/XpmImagePlugin.py +157 -0
  90. package/lib/python3.14/site-packages/PIL/__init__.py +87 -0
  91. package/lib/python3.14/site-packages/PIL/__main__.py +7 -0
  92. package/lib/python3.14/site-packages/PIL/__pycache__/AvifImagePlugin.cpython-314.pyc +0 -0
  93. package/lib/python3.14/site-packages/PIL/__pycache__/BdfFontFile.cpython-314.pyc +0 -0
  94. package/lib/python3.14/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-314.pyc +0 -0
  95. package/lib/python3.14/site-packages/PIL/__pycache__/BmpImagePlugin.cpython-314.pyc +0 -0
  96. package/lib/python3.14/site-packages/PIL/__pycache__/BufrStubImagePlugin.cpython-314.pyc +0 -0
  97. package/lib/python3.14/site-packages/PIL/__pycache__/ContainerIO.cpython-314.pyc +0 -0
  98. package/lib/python3.14/site-packages/PIL/__pycache__/CurImagePlugin.cpython-314.pyc +0 -0
  99. package/lib/python3.14/site-packages/PIL/__pycache__/DcxImagePlugin.cpython-314.pyc +0 -0
  100. package/lib/python3.14/site-packages/PIL/__pycache__/DdsImagePlugin.cpython-314.pyc +0 -0
  101. package/lib/python3.14/site-packages/PIL/__pycache__/EpsImagePlugin.cpython-314.pyc +0 -0
  102. package/lib/python3.14/site-packages/PIL/__pycache__/ExifTags.cpython-314.pyc +0 -0
  103. package/lib/python3.14/site-packages/PIL/__pycache__/FitsImagePlugin.cpython-314.pyc +0 -0
  104. package/lib/python3.14/site-packages/PIL/__pycache__/FliImagePlugin.cpython-314.pyc +0 -0
  105. package/lib/python3.14/site-packages/PIL/__pycache__/FontFile.cpython-314.pyc +0 -0
  106. package/lib/python3.14/site-packages/PIL/__pycache__/FpxImagePlugin.cpython-314.pyc +0 -0
  107. package/lib/python3.14/site-packages/PIL/__pycache__/FtexImagePlugin.cpython-314.pyc +0 -0
  108. package/lib/python3.14/site-packages/PIL/__pycache__/GbrImagePlugin.cpython-314.pyc +0 -0
  109. package/lib/python3.14/site-packages/PIL/__pycache__/GdImageFile.cpython-314.pyc +0 -0
  110. package/lib/python3.14/site-packages/PIL/__pycache__/GifImagePlugin.cpython-314.pyc +0 -0
  111. package/lib/python3.14/site-packages/PIL/__pycache__/GimpGradientFile.cpython-314.pyc +0 -0
  112. package/lib/python3.14/site-packages/PIL/__pycache__/GimpPaletteFile.cpython-314.pyc +0 -0
  113. package/lib/python3.14/site-packages/PIL/__pycache__/GribStubImagePlugin.cpython-314.pyc +0 -0
  114. package/lib/python3.14/site-packages/PIL/__pycache__/Hdf5StubImagePlugin.cpython-314.pyc +0 -0
  115. package/lib/python3.14/site-packages/PIL/__pycache__/IcnsImagePlugin.cpython-314.pyc +0 -0
  116. package/lib/python3.14/site-packages/PIL/__pycache__/IcoImagePlugin.cpython-314.pyc +0 -0
  117. package/lib/python3.14/site-packages/PIL/__pycache__/ImImagePlugin.cpython-314.pyc +0 -0
  118. package/lib/python3.14/site-packages/PIL/__pycache__/Image.cpython-314.pyc +0 -0
  119. package/lib/python3.14/site-packages/PIL/__pycache__/ImageChops.cpython-314.pyc +0 -0
  120. package/lib/python3.14/site-packages/PIL/__pycache__/ImageCms.cpython-314.pyc +0 -0
  121. package/lib/python3.14/site-packages/PIL/__pycache__/ImageColor.cpython-314.pyc +0 -0
  122. package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw.cpython-314.pyc +0 -0
  123. package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw2.cpython-314.pyc +0 -0
  124. package/lib/python3.14/site-packages/PIL/__pycache__/ImageEnhance.cpython-314.pyc +0 -0
  125. package/lib/python3.14/site-packages/PIL/__pycache__/ImageFile.cpython-314.pyc +0 -0
  126. package/lib/python3.14/site-packages/PIL/__pycache__/ImageFilter.cpython-314.pyc +0 -0
  127. package/lib/python3.14/site-packages/PIL/__pycache__/ImageFont.cpython-314.pyc +0 -0
  128. package/lib/python3.14/site-packages/PIL/__pycache__/ImageGrab.cpython-314.pyc +0 -0
  129. package/lib/python3.14/site-packages/PIL/__pycache__/ImageMath.cpython-314.pyc +0 -0
  130. package/lib/python3.14/site-packages/PIL/__pycache__/ImageMode.cpython-314.pyc +0 -0
  131. package/lib/python3.14/site-packages/PIL/__pycache__/ImageMorph.cpython-314.pyc +0 -0
  132. package/lib/python3.14/site-packages/PIL/__pycache__/ImageOps.cpython-314.pyc +0 -0
  133. package/lib/python3.14/site-packages/PIL/__pycache__/ImagePalette.cpython-314.pyc +0 -0
  134. package/lib/python3.14/site-packages/PIL/__pycache__/ImagePath.cpython-314.pyc +0 -0
  135. package/lib/python3.14/site-packages/PIL/__pycache__/ImageQt.cpython-314.pyc +0 -0
  136. package/lib/python3.14/site-packages/PIL/__pycache__/ImageSequence.cpython-314.pyc +0 -0
  137. package/lib/python3.14/site-packages/PIL/__pycache__/ImageShow.cpython-314.pyc +0 -0
  138. package/lib/python3.14/site-packages/PIL/__pycache__/ImageStat.cpython-314.pyc +0 -0
  139. package/lib/python3.14/site-packages/PIL/__pycache__/ImageText.cpython-314.pyc +0 -0
  140. package/lib/python3.14/site-packages/PIL/__pycache__/ImageTk.cpython-314.pyc +0 -0
  141. package/lib/python3.14/site-packages/PIL/__pycache__/ImageTransform.cpython-314.pyc +0 -0
  142. package/lib/python3.14/site-packages/PIL/__pycache__/ImageWin.cpython-314.pyc +0 -0
  143. package/lib/python3.14/site-packages/PIL/__pycache__/ImtImagePlugin.cpython-314.pyc +0 -0
  144. package/lib/python3.14/site-packages/PIL/__pycache__/IptcImagePlugin.cpython-314.pyc +0 -0
  145. package/lib/python3.14/site-packages/PIL/__pycache__/Jpeg2KImagePlugin.cpython-314.pyc +0 -0
  146. package/lib/python3.14/site-packages/PIL/__pycache__/JpegImagePlugin.cpython-314.pyc +0 -0
  147. package/lib/python3.14/site-packages/PIL/__pycache__/JpegPresets.cpython-314.pyc +0 -0
  148. package/lib/python3.14/site-packages/PIL/__pycache__/McIdasImagePlugin.cpython-314.pyc +0 -0
  149. package/lib/python3.14/site-packages/PIL/__pycache__/MicImagePlugin.cpython-314.pyc +0 -0
  150. package/lib/python3.14/site-packages/PIL/__pycache__/MpegImagePlugin.cpython-314.pyc +0 -0
  151. package/lib/python3.14/site-packages/PIL/__pycache__/MpoImagePlugin.cpython-314.pyc +0 -0
  152. package/lib/python3.14/site-packages/PIL/__pycache__/MspImagePlugin.cpython-314.pyc +0 -0
  153. package/lib/python3.14/site-packages/PIL/__pycache__/PSDraw.cpython-314.pyc +0 -0
  154. package/lib/python3.14/site-packages/PIL/__pycache__/PaletteFile.cpython-314.pyc +0 -0
  155. package/lib/python3.14/site-packages/PIL/__pycache__/PalmImagePlugin.cpython-314.pyc +0 -0
  156. package/lib/python3.14/site-packages/PIL/__pycache__/PcdImagePlugin.cpython-314.pyc +0 -0
  157. package/lib/python3.14/site-packages/PIL/__pycache__/PcfFontFile.cpython-314.pyc +0 -0
  158. package/lib/python3.14/site-packages/PIL/__pycache__/PcxImagePlugin.cpython-314.pyc +0 -0
  159. package/lib/python3.14/site-packages/PIL/__pycache__/PdfImagePlugin.cpython-314.pyc +0 -0
  160. package/lib/python3.14/site-packages/PIL/__pycache__/PdfParser.cpython-314.pyc +0 -0
  161. package/lib/python3.14/site-packages/PIL/__pycache__/PixarImagePlugin.cpython-314.pyc +0 -0
  162. package/lib/python3.14/site-packages/PIL/__pycache__/PngImagePlugin.cpython-314.pyc +0 -0
  163. package/lib/python3.14/site-packages/PIL/__pycache__/PpmImagePlugin.cpython-314.pyc +0 -0
  164. package/lib/python3.14/site-packages/PIL/__pycache__/PsdImagePlugin.cpython-314.pyc +0 -0
  165. package/lib/python3.14/site-packages/PIL/__pycache__/QoiImagePlugin.cpython-314.pyc +0 -0
  166. package/lib/python3.14/site-packages/PIL/__pycache__/SgiImagePlugin.cpython-314.pyc +0 -0
  167. package/lib/python3.14/site-packages/PIL/__pycache__/SpiderImagePlugin.cpython-314.pyc +0 -0
  168. package/lib/python3.14/site-packages/PIL/__pycache__/SunImagePlugin.cpython-314.pyc +0 -0
  169. package/lib/python3.14/site-packages/PIL/__pycache__/TarIO.cpython-314.pyc +0 -0
  170. package/lib/python3.14/site-packages/PIL/__pycache__/TgaImagePlugin.cpython-314.pyc +0 -0
  171. package/lib/python3.14/site-packages/PIL/__pycache__/TiffImagePlugin.cpython-314.pyc +0 -0
  172. package/lib/python3.14/site-packages/PIL/__pycache__/TiffTags.cpython-314.pyc +0 -0
  173. package/lib/python3.14/site-packages/PIL/__pycache__/WalImageFile.cpython-314.pyc +0 -0
  174. package/lib/python3.14/site-packages/PIL/__pycache__/WebPImagePlugin.cpython-314.pyc +0 -0
  175. package/lib/python3.14/site-packages/PIL/__pycache__/WmfImagePlugin.cpython-314.pyc +0 -0
  176. package/lib/python3.14/site-packages/PIL/__pycache__/XVThumbImagePlugin.cpython-314.pyc +0 -0
  177. package/lib/python3.14/site-packages/PIL/__pycache__/XbmImagePlugin.cpython-314.pyc +0 -0
  178. package/lib/python3.14/site-packages/PIL/__pycache__/XpmImagePlugin.cpython-314.pyc +0 -0
  179. package/lib/python3.14/site-packages/PIL/__pycache__/__init__.cpython-314.pyc +0 -0
  180. package/lib/python3.14/site-packages/PIL/__pycache__/__main__.cpython-314.pyc +0 -0
  181. package/lib/python3.14/site-packages/PIL/__pycache__/_binary.cpython-314.pyc +0 -0
  182. package/lib/python3.14/site-packages/PIL/__pycache__/_deprecate.cpython-314.pyc +0 -0
  183. package/lib/python3.14/site-packages/PIL/__pycache__/_tkinter_finder.cpython-314.pyc +0 -0
  184. package/lib/python3.14/site-packages/PIL/__pycache__/_typing.cpython-314.pyc +0 -0
  185. package/lib/python3.14/site-packages/PIL/__pycache__/_util.cpython-314.pyc +0 -0
  186. package/lib/python3.14/site-packages/PIL/__pycache__/_version.cpython-314.pyc +0 -0
  187. package/lib/python3.14/site-packages/PIL/__pycache__/features.cpython-314.pyc +0 -0
  188. package/lib/python3.14/site-packages/PIL/__pycache__/report.cpython-314.pyc +0 -0
  189. package/lib/python3.14/site-packages/PIL/_avif.pyi +3 -0
  190. package/lib/python3.14/site-packages/PIL/_binary.py +113 -0
  191. package/lib/python3.14/site-packages/PIL/_deprecate.py +72 -0
  192. package/lib/python3.14/site-packages/PIL/_imaging.cpython-314-wasm32-wasix.so +0 -0
  193. package/lib/python3.14/site-packages/PIL/_imaging.pyi +31 -0
  194. package/lib/python3.14/site-packages/PIL/_imagingcms.pyi +143 -0
  195. package/lib/python3.14/site-packages/PIL/_imagingft.cpython-314-wasm32-wasix.so +0 -0
  196. package/lib/python3.14/site-packages/PIL/_imagingft.pyi +70 -0
  197. package/lib/python3.14/site-packages/PIL/_imagingmath.cpython-314-wasm32-wasix.so +0 -0
  198. package/lib/python3.14/site-packages/PIL/_imagingmath.pyi +3 -0
  199. package/lib/python3.14/site-packages/PIL/_imagingmorph.cpython-314-wasm32-wasix.so +0 -0
  200. package/lib/python3.14/site-packages/PIL/_imagingmorph.pyi +3 -0
  201. package/lib/python3.14/site-packages/PIL/_imagingtk.cpython-314-wasm32-wasix.so +0 -0
  202. package/lib/python3.14/site-packages/PIL/_imagingtk.pyi +3 -0
  203. package/lib/python3.14/site-packages/PIL/_tkinter_finder.py +20 -0
  204. package/lib/python3.14/site-packages/PIL/_typing.py +45 -0
  205. package/lib/python3.14/site-packages/PIL/_util.py +29 -0
  206. package/lib/python3.14/site-packages/PIL/_version.py +4 -0
  207. package/lib/python3.14/site-packages/PIL/_webp.pyi +3 -0
  208. package/lib/python3.14/site-packages/PIL/features.py +343 -0
  209. package/lib/python3.14/site-packages/PIL/py.typed +0 -0
  210. package/lib/python3.14/site-packages/PIL/report.py +5 -0
  211. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/METADATA +180 -0
  212. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/RECORD +117 -0
  213. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/WHEEL +5 -0
  214. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/licenses/LICENSE +30 -0
  215. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/top_level.txt +1 -0
  216. package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/zip-safe +1 -0
  217. 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
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+
5
+ from .features import pilinfo
6
+
7
+ pilinfo(supported_formats="--report" not in sys.argv)
@@ -0,0 +1,3 @@
1
+ from typing import Any
2
+
3
+ def __getattr__(name: str) -> Any: ...
@@ -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)