@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,384 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# EXIF tags
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2003 by Secret Labs AB
|
|
8
|
+
#
|
|
9
|
+
# See the README file for information on usage and redistribution.
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
This module provides constants and clear-text names for various
|
|
14
|
+
well-known EXIF tags.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from enum import IntEnum
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Base(IntEnum):
|
|
23
|
+
# possibly incomplete
|
|
24
|
+
InteropIndex = 0x0001
|
|
25
|
+
ProcessingSoftware = 0x000B
|
|
26
|
+
NewSubfileType = 0x00FE
|
|
27
|
+
SubfileType = 0x00FF
|
|
28
|
+
ImageWidth = 0x0100
|
|
29
|
+
ImageLength = 0x0101
|
|
30
|
+
BitsPerSample = 0x0102
|
|
31
|
+
Compression = 0x0103
|
|
32
|
+
PhotometricInterpretation = 0x0106
|
|
33
|
+
Thresholding = 0x0107
|
|
34
|
+
CellWidth = 0x0108
|
|
35
|
+
CellLength = 0x0109
|
|
36
|
+
FillOrder = 0x010A
|
|
37
|
+
DocumentName = 0x010D
|
|
38
|
+
ImageDescription = 0x010E
|
|
39
|
+
Make = 0x010F
|
|
40
|
+
Model = 0x0110
|
|
41
|
+
StripOffsets = 0x0111
|
|
42
|
+
Orientation = 0x0112
|
|
43
|
+
SamplesPerPixel = 0x0115
|
|
44
|
+
RowsPerStrip = 0x0116
|
|
45
|
+
StripByteCounts = 0x0117
|
|
46
|
+
MinSampleValue = 0x0118
|
|
47
|
+
MaxSampleValue = 0x0119
|
|
48
|
+
XResolution = 0x011A
|
|
49
|
+
YResolution = 0x011B
|
|
50
|
+
PlanarConfiguration = 0x011C
|
|
51
|
+
PageName = 0x011D
|
|
52
|
+
FreeOffsets = 0x0120
|
|
53
|
+
FreeByteCounts = 0x0121
|
|
54
|
+
GrayResponseUnit = 0x0122
|
|
55
|
+
GrayResponseCurve = 0x0123
|
|
56
|
+
T4Options = 0x0124
|
|
57
|
+
T6Options = 0x0125
|
|
58
|
+
ResolutionUnit = 0x0128
|
|
59
|
+
PageNumber = 0x0129
|
|
60
|
+
TransferFunction = 0x012D
|
|
61
|
+
Software = 0x0131
|
|
62
|
+
DateTime = 0x0132
|
|
63
|
+
Artist = 0x013B
|
|
64
|
+
HostComputer = 0x013C
|
|
65
|
+
Predictor = 0x013D
|
|
66
|
+
WhitePoint = 0x013E
|
|
67
|
+
PrimaryChromaticities = 0x013F
|
|
68
|
+
ColorMap = 0x0140
|
|
69
|
+
HalftoneHints = 0x0141
|
|
70
|
+
TileWidth = 0x0142
|
|
71
|
+
TileLength = 0x0143
|
|
72
|
+
TileOffsets = 0x0144
|
|
73
|
+
TileByteCounts = 0x0145
|
|
74
|
+
SubIFDs = 0x014A
|
|
75
|
+
InkSet = 0x014C
|
|
76
|
+
InkNames = 0x014D
|
|
77
|
+
NumberOfInks = 0x014E
|
|
78
|
+
DotRange = 0x0150
|
|
79
|
+
TargetPrinter = 0x0151
|
|
80
|
+
ExtraSamples = 0x0152
|
|
81
|
+
SampleFormat = 0x0153
|
|
82
|
+
SMinSampleValue = 0x0154
|
|
83
|
+
SMaxSampleValue = 0x0155
|
|
84
|
+
TransferRange = 0x0156
|
|
85
|
+
ClipPath = 0x0157
|
|
86
|
+
XClipPathUnits = 0x0158
|
|
87
|
+
YClipPathUnits = 0x0159
|
|
88
|
+
Indexed = 0x015A
|
|
89
|
+
JPEGTables = 0x015B
|
|
90
|
+
OPIProxy = 0x015F
|
|
91
|
+
JPEGProc = 0x0200
|
|
92
|
+
JpegIFOffset = 0x0201
|
|
93
|
+
JpegIFByteCount = 0x0202
|
|
94
|
+
JpegRestartInterval = 0x0203
|
|
95
|
+
JpegLosslessPredictors = 0x0205
|
|
96
|
+
JpegPointTransforms = 0x0206
|
|
97
|
+
JpegQTables = 0x0207
|
|
98
|
+
JpegDCTables = 0x0208
|
|
99
|
+
JpegACTables = 0x0209
|
|
100
|
+
YCbCrCoefficients = 0x0211
|
|
101
|
+
YCbCrSubSampling = 0x0212
|
|
102
|
+
YCbCrPositioning = 0x0213
|
|
103
|
+
ReferenceBlackWhite = 0x0214
|
|
104
|
+
XMLPacket = 0x02BC
|
|
105
|
+
RelatedImageFileFormat = 0x1000
|
|
106
|
+
RelatedImageWidth = 0x1001
|
|
107
|
+
RelatedImageLength = 0x1002
|
|
108
|
+
Rating = 0x4746
|
|
109
|
+
RatingPercent = 0x4749
|
|
110
|
+
ImageID = 0x800D
|
|
111
|
+
CFARepeatPatternDim = 0x828D
|
|
112
|
+
BatteryLevel = 0x828F
|
|
113
|
+
Copyright = 0x8298
|
|
114
|
+
ExposureTime = 0x829A
|
|
115
|
+
FNumber = 0x829D
|
|
116
|
+
IPTCNAA = 0x83BB
|
|
117
|
+
ImageResources = 0x8649
|
|
118
|
+
ExifOffset = 0x8769
|
|
119
|
+
InterColorProfile = 0x8773
|
|
120
|
+
ExposureProgram = 0x8822
|
|
121
|
+
SpectralSensitivity = 0x8824
|
|
122
|
+
GPSInfo = 0x8825
|
|
123
|
+
ISOSpeedRatings = 0x8827
|
|
124
|
+
OECF = 0x8828
|
|
125
|
+
Interlace = 0x8829
|
|
126
|
+
TimeZoneOffset = 0x882A
|
|
127
|
+
SelfTimerMode = 0x882B
|
|
128
|
+
SensitivityType = 0x8830
|
|
129
|
+
StandardOutputSensitivity = 0x8831
|
|
130
|
+
RecommendedExposureIndex = 0x8832
|
|
131
|
+
ISOSpeed = 0x8833
|
|
132
|
+
ISOSpeedLatitudeyyy = 0x8834
|
|
133
|
+
ISOSpeedLatitudezzz = 0x8835
|
|
134
|
+
ExifVersion = 0x9000
|
|
135
|
+
DateTimeOriginal = 0x9003
|
|
136
|
+
DateTimeDigitized = 0x9004
|
|
137
|
+
OffsetTime = 0x9010
|
|
138
|
+
OffsetTimeOriginal = 0x9011
|
|
139
|
+
OffsetTimeDigitized = 0x9012
|
|
140
|
+
ComponentsConfiguration = 0x9101
|
|
141
|
+
CompressedBitsPerPixel = 0x9102
|
|
142
|
+
ShutterSpeedValue = 0x9201
|
|
143
|
+
ApertureValue = 0x9202
|
|
144
|
+
BrightnessValue = 0x9203
|
|
145
|
+
ExposureBiasValue = 0x9204
|
|
146
|
+
MaxApertureValue = 0x9205
|
|
147
|
+
SubjectDistance = 0x9206
|
|
148
|
+
MeteringMode = 0x9207
|
|
149
|
+
LightSource = 0x9208
|
|
150
|
+
Flash = 0x9209
|
|
151
|
+
FocalLength = 0x920A
|
|
152
|
+
Noise = 0x920D
|
|
153
|
+
ImageNumber = 0x9211
|
|
154
|
+
SecurityClassification = 0x9212
|
|
155
|
+
ImageHistory = 0x9213
|
|
156
|
+
TIFFEPStandardID = 0x9216
|
|
157
|
+
MakerNote = 0x927C
|
|
158
|
+
UserComment = 0x9286
|
|
159
|
+
SubsecTime = 0x9290
|
|
160
|
+
SubsecTimeOriginal = 0x9291
|
|
161
|
+
SubsecTimeDigitized = 0x9292
|
|
162
|
+
AmbientTemperature = 0x9400
|
|
163
|
+
Humidity = 0x9401
|
|
164
|
+
Pressure = 0x9402
|
|
165
|
+
WaterDepth = 0x9403
|
|
166
|
+
Acceleration = 0x9404
|
|
167
|
+
CameraElevationAngle = 0x9405
|
|
168
|
+
XPTitle = 0x9C9B
|
|
169
|
+
XPComment = 0x9C9C
|
|
170
|
+
XPAuthor = 0x9C9D
|
|
171
|
+
XPKeywords = 0x9C9E
|
|
172
|
+
XPSubject = 0x9C9F
|
|
173
|
+
FlashPixVersion = 0xA000
|
|
174
|
+
ColorSpace = 0xA001
|
|
175
|
+
ExifImageWidth = 0xA002
|
|
176
|
+
ExifImageHeight = 0xA003
|
|
177
|
+
RelatedSoundFile = 0xA004
|
|
178
|
+
ExifInteroperabilityOffset = 0xA005
|
|
179
|
+
FlashEnergy = 0xA20B
|
|
180
|
+
SpatialFrequencyResponse = 0xA20C
|
|
181
|
+
FocalPlaneXResolution = 0xA20E
|
|
182
|
+
FocalPlaneYResolution = 0xA20F
|
|
183
|
+
FocalPlaneResolutionUnit = 0xA210
|
|
184
|
+
SubjectLocation = 0xA214
|
|
185
|
+
ExposureIndex = 0xA215
|
|
186
|
+
SensingMethod = 0xA217
|
|
187
|
+
FileSource = 0xA300
|
|
188
|
+
SceneType = 0xA301
|
|
189
|
+
CFAPattern = 0xA302
|
|
190
|
+
CustomRendered = 0xA401
|
|
191
|
+
ExposureMode = 0xA402
|
|
192
|
+
WhiteBalance = 0xA403
|
|
193
|
+
DigitalZoomRatio = 0xA404
|
|
194
|
+
FocalLengthIn35mmFilm = 0xA405
|
|
195
|
+
SceneCaptureType = 0xA406
|
|
196
|
+
GainControl = 0xA407
|
|
197
|
+
Contrast = 0xA408
|
|
198
|
+
Saturation = 0xA409
|
|
199
|
+
Sharpness = 0xA40A
|
|
200
|
+
DeviceSettingDescription = 0xA40B
|
|
201
|
+
SubjectDistanceRange = 0xA40C
|
|
202
|
+
ImageUniqueID = 0xA420
|
|
203
|
+
CameraOwnerName = 0xA430
|
|
204
|
+
BodySerialNumber = 0xA431
|
|
205
|
+
LensSpecification = 0xA432
|
|
206
|
+
LensMake = 0xA433
|
|
207
|
+
LensModel = 0xA434
|
|
208
|
+
LensSerialNumber = 0xA435
|
|
209
|
+
CompositeImage = 0xA460
|
|
210
|
+
CompositeImageCount = 0xA461
|
|
211
|
+
CompositeImageExposureTimes = 0xA462
|
|
212
|
+
Gamma = 0xA500
|
|
213
|
+
PrintImageMatching = 0xC4A5
|
|
214
|
+
DNGVersion = 0xC612
|
|
215
|
+
DNGBackwardVersion = 0xC613
|
|
216
|
+
UniqueCameraModel = 0xC614
|
|
217
|
+
LocalizedCameraModel = 0xC615
|
|
218
|
+
CFAPlaneColor = 0xC616
|
|
219
|
+
CFALayout = 0xC617
|
|
220
|
+
LinearizationTable = 0xC618
|
|
221
|
+
BlackLevelRepeatDim = 0xC619
|
|
222
|
+
BlackLevel = 0xC61A
|
|
223
|
+
BlackLevelDeltaH = 0xC61B
|
|
224
|
+
BlackLevelDeltaV = 0xC61C
|
|
225
|
+
WhiteLevel = 0xC61D
|
|
226
|
+
DefaultScale = 0xC61E
|
|
227
|
+
DefaultCropOrigin = 0xC61F
|
|
228
|
+
DefaultCropSize = 0xC620
|
|
229
|
+
ColorMatrix1 = 0xC621
|
|
230
|
+
ColorMatrix2 = 0xC622
|
|
231
|
+
CameraCalibration1 = 0xC623
|
|
232
|
+
CameraCalibration2 = 0xC624
|
|
233
|
+
ReductionMatrix1 = 0xC625
|
|
234
|
+
ReductionMatrix2 = 0xC626
|
|
235
|
+
AnalogBalance = 0xC627
|
|
236
|
+
AsShotNeutral = 0xC628
|
|
237
|
+
AsShotWhiteXY = 0xC629
|
|
238
|
+
BaselineExposure = 0xC62A
|
|
239
|
+
BaselineNoise = 0xC62B
|
|
240
|
+
BaselineSharpness = 0xC62C
|
|
241
|
+
BayerGreenSplit = 0xC62D
|
|
242
|
+
LinearResponseLimit = 0xC62E
|
|
243
|
+
CameraSerialNumber = 0xC62F
|
|
244
|
+
LensInfo = 0xC630
|
|
245
|
+
ChromaBlurRadius = 0xC631
|
|
246
|
+
AntiAliasStrength = 0xC632
|
|
247
|
+
ShadowScale = 0xC633
|
|
248
|
+
DNGPrivateData = 0xC634
|
|
249
|
+
MakerNoteSafety = 0xC635
|
|
250
|
+
CalibrationIlluminant1 = 0xC65A
|
|
251
|
+
CalibrationIlluminant2 = 0xC65B
|
|
252
|
+
BestQualityScale = 0xC65C
|
|
253
|
+
RawDataUniqueID = 0xC65D
|
|
254
|
+
OriginalRawFileName = 0xC68B
|
|
255
|
+
OriginalRawFileData = 0xC68C
|
|
256
|
+
ActiveArea = 0xC68D
|
|
257
|
+
MaskedAreas = 0xC68E
|
|
258
|
+
AsShotICCProfile = 0xC68F
|
|
259
|
+
AsShotPreProfileMatrix = 0xC690
|
|
260
|
+
CurrentICCProfile = 0xC691
|
|
261
|
+
CurrentPreProfileMatrix = 0xC692
|
|
262
|
+
ColorimetricReference = 0xC6BF
|
|
263
|
+
CameraCalibrationSignature = 0xC6F3
|
|
264
|
+
ProfileCalibrationSignature = 0xC6F4
|
|
265
|
+
AsShotProfileName = 0xC6F6
|
|
266
|
+
NoiseReductionApplied = 0xC6F7
|
|
267
|
+
ProfileName = 0xC6F8
|
|
268
|
+
ProfileHueSatMapDims = 0xC6F9
|
|
269
|
+
ProfileHueSatMapData1 = 0xC6FA
|
|
270
|
+
ProfileHueSatMapData2 = 0xC6FB
|
|
271
|
+
ProfileToneCurve = 0xC6FC
|
|
272
|
+
ProfileEmbedPolicy = 0xC6FD
|
|
273
|
+
ProfileCopyright = 0xC6FE
|
|
274
|
+
ForwardMatrix1 = 0xC714
|
|
275
|
+
ForwardMatrix2 = 0xC715
|
|
276
|
+
PreviewApplicationName = 0xC716
|
|
277
|
+
PreviewApplicationVersion = 0xC717
|
|
278
|
+
PreviewSettingsName = 0xC718
|
|
279
|
+
PreviewSettingsDigest = 0xC719
|
|
280
|
+
PreviewColorSpace = 0xC71A
|
|
281
|
+
PreviewDateTime = 0xC71B
|
|
282
|
+
RawImageDigest = 0xC71C
|
|
283
|
+
OriginalRawFileDigest = 0xC71D
|
|
284
|
+
SubTileBlockSize = 0xC71E
|
|
285
|
+
RowInterleaveFactor = 0xC71F
|
|
286
|
+
ProfileLookTableDims = 0xC725
|
|
287
|
+
ProfileLookTableData = 0xC726
|
|
288
|
+
OpcodeList1 = 0xC740
|
|
289
|
+
OpcodeList2 = 0xC741
|
|
290
|
+
OpcodeList3 = 0xC74E
|
|
291
|
+
NoiseProfile = 0xC761
|
|
292
|
+
FrameRate = 0xC764
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
"""Maps EXIF tags to tag names."""
|
|
296
|
+
TAGS = {
|
|
297
|
+
**{i.value: i.name for i in Base},
|
|
298
|
+
0x920C: "SpatialFrequencyResponse",
|
|
299
|
+
0x9214: "SubjectLocation",
|
|
300
|
+
0x9215: "ExposureIndex",
|
|
301
|
+
0x828E: "CFAPattern",
|
|
302
|
+
0x920B: "FlashEnergy",
|
|
303
|
+
0x9216: "TIFF/EPStandardID",
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class GPS(IntEnum):
|
|
308
|
+
GPSVersionID = 0x00
|
|
309
|
+
GPSLatitudeRef = 0x01
|
|
310
|
+
GPSLatitude = 0x02
|
|
311
|
+
GPSLongitudeRef = 0x03
|
|
312
|
+
GPSLongitude = 0x04
|
|
313
|
+
GPSAltitudeRef = 0x05
|
|
314
|
+
GPSAltitude = 0x06
|
|
315
|
+
GPSTimeStamp = 0x07
|
|
316
|
+
GPSSatellites = 0x08
|
|
317
|
+
GPSStatus = 0x09
|
|
318
|
+
GPSMeasureMode = 0x0A
|
|
319
|
+
GPSDOP = 0x0B
|
|
320
|
+
GPSSpeedRef = 0x0C
|
|
321
|
+
GPSSpeed = 0x0D
|
|
322
|
+
GPSTrackRef = 0x0E
|
|
323
|
+
GPSTrack = 0x0F
|
|
324
|
+
GPSImgDirectionRef = 0x10
|
|
325
|
+
GPSImgDirection = 0x11
|
|
326
|
+
GPSMapDatum = 0x12
|
|
327
|
+
GPSDestLatitudeRef = 0x13
|
|
328
|
+
GPSDestLatitude = 0x14
|
|
329
|
+
GPSDestLongitudeRef = 0x15
|
|
330
|
+
GPSDestLongitude = 0x16
|
|
331
|
+
GPSDestBearingRef = 0x17
|
|
332
|
+
GPSDestBearing = 0x18
|
|
333
|
+
GPSDestDistanceRef = 0x19
|
|
334
|
+
GPSDestDistance = 0x1A
|
|
335
|
+
GPSProcessingMethod = 0x1B
|
|
336
|
+
GPSAreaInformation = 0x1C
|
|
337
|
+
GPSDateStamp = 0x1D
|
|
338
|
+
GPSDifferential = 0x1E
|
|
339
|
+
GPSHPositioningError = 0x1F
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
"""Maps EXIF GPS tags to tag names."""
|
|
343
|
+
GPSTAGS = {i.value: i.name for i in GPS}
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
class Interop(IntEnum):
|
|
347
|
+
InteropIndex = 0x0001
|
|
348
|
+
InteropVersion = 0x0002
|
|
349
|
+
RelatedImageFileFormat = 0x1000
|
|
350
|
+
RelatedImageWidth = 0x1001
|
|
351
|
+
RelatedImageHeight = 0x1002
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class IFD(IntEnum):
|
|
355
|
+
Exif = 0x8769
|
|
356
|
+
GPSInfo = 0x8825
|
|
357
|
+
MakerNote = 0x927C
|
|
358
|
+
Makernote = 0x927C # Deprecated
|
|
359
|
+
Interop = 0xA005
|
|
360
|
+
IFD1 = -1
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class LightSource(IntEnum):
|
|
364
|
+
Unknown = 0x00
|
|
365
|
+
Daylight = 0x01
|
|
366
|
+
Fluorescent = 0x02
|
|
367
|
+
Tungsten = 0x03
|
|
368
|
+
Flash = 0x04
|
|
369
|
+
Fine = 0x09
|
|
370
|
+
Cloudy = 0x0A
|
|
371
|
+
Shade = 0x0B
|
|
372
|
+
DaylightFluorescent = 0x0C
|
|
373
|
+
DayWhiteFluorescent = 0x0D
|
|
374
|
+
CoolWhiteFluorescent = 0x0E
|
|
375
|
+
WhiteFluorescent = 0x0F
|
|
376
|
+
StandardLightA = 0x11
|
|
377
|
+
StandardLightB = 0x12
|
|
378
|
+
StandardLightC = 0x13
|
|
379
|
+
D55 = 0x14
|
|
380
|
+
D65 = 0x15
|
|
381
|
+
D75 = 0x16
|
|
382
|
+
D50 = 0x17
|
|
383
|
+
ISO = 0x18
|
|
384
|
+
Other = 0xFF
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# FITS file handling
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 1998-2003 by Fredrik Lundh
|
|
8
|
+
#
|
|
9
|
+
# See the README file for information on usage and redistribution.
|
|
10
|
+
#
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import gzip
|
|
14
|
+
import math
|
|
15
|
+
|
|
16
|
+
from . import Image, ImageFile
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _accept(prefix: bytes) -> bool:
|
|
20
|
+
return prefix.startswith(b"SIMPLE")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class FitsImageFile(ImageFile.ImageFile):
|
|
24
|
+
format = "FITS"
|
|
25
|
+
format_description = "FITS"
|
|
26
|
+
|
|
27
|
+
def _open(self) -> None:
|
|
28
|
+
assert self.fp is not None
|
|
29
|
+
|
|
30
|
+
headers: dict[bytes, bytes] = {}
|
|
31
|
+
header_in_progress = False
|
|
32
|
+
decoder_name = ""
|
|
33
|
+
while True:
|
|
34
|
+
header = self.fp.read(80)
|
|
35
|
+
if not header:
|
|
36
|
+
msg = "Truncated FITS file"
|
|
37
|
+
raise OSError(msg)
|
|
38
|
+
keyword = header[:8].strip()
|
|
39
|
+
if keyword in (b"SIMPLE", b"XTENSION"):
|
|
40
|
+
header_in_progress = True
|
|
41
|
+
elif headers and not header_in_progress:
|
|
42
|
+
# This is now a data unit
|
|
43
|
+
break
|
|
44
|
+
elif keyword == b"END":
|
|
45
|
+
# Seek to the end of the header unit
|
|
46
|
+
self.fp.seek(math.ceil(self.fp.tell() / 2880) * 2880)
|
|
47
|
+
if not decoder_name:
|
|
48
|
+
decoder_name, offset, args = self._parse_headers(headers)
|
|
49
|
+
|
|
50
|
+
header_in_progress = False
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
if decoder_name:
|
|
54
|
+
# Keep going to read past the headers
|
|
55
|
+
continue
|
|
56
|
+
|
|
57
|
+
value = header[8:].split(b"/")[0].strip()
|
|
58
|
+
if value.startswith(b"="):
|
|
59
|
+
value = value[1:].strip()
|
|
60
|
+
if not headers and (not _accept(keyword) or value != b"T"):
|
|
61
|
+
msg = "Not a FITS file"
|
|
62
|
+
raise SyntaxError(msg)
|
|
63
|
+
headers[keyword] = value
|
|
64
|
+
|
|
65
|
+
if not decoder_name:
|
|
66
|
+
msg = "No image data"
|
|
67
|
+
raise ValueError(msg)
|
|
68
|
+
|
|
69
|
+
offset += self.fp.tell() - 80
|
|
70
|
+
self.tile = [ImageFile._Tile(decoder_name, (0, 0) + self.size, offset, args)]
|
|
71
|
+
|
|
72
|
+
def _get_size(
|
|
73
|
+
self, headers: dict[bytes, bytes], prefix: bytes
|
|
74
|
+
) -> tuple[int, int] | None:
|
|
75
|
+
naxis = int(headers[prefix + b"NAXIS"])
|
|
76
|
+
if naxis == 0:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
if naxis == 1:
|
|
80
|
+
return 1, int(headers[prefix + b"NAXIS1"])
|
|
81
|
+
else:
|
|
82
|
+
return int(headers[prefix + b"NAXIS1"]), int(headers[prefix + b"NAXIS2"])
|
|
83
|
+
|
|
84
|
+
def _parse_headers(
|
|
85
|
+
self, headers: dict[bytes, bytes]
|
|
86
|
+
) -> tuple[str, int, tuple[str | int, ...]]:
|
|
87
|
+
prefix = b""
|
|
88
|
+
decoder_name = "raw"
|
|
89
|
+
offset = 0
|
|
90
|
+
if (
|
|
91
|
+
headers.get(b"XTENSION") == b"'BINTABLE'"
|
|
92
|
+
and headers.get(b"ZIMAGE") == b"T"
|
|
93
|
+
and headers[b"ZCMPTYPE"] == b"'GZIP_1 '"
|
|
94
|
+
):
|
|
95
|
+
no_prefix_size = self._get_size(headers, prefix) or (0, 0)
|
|
96
|
+
number_of_bits = int(headers[b"BITPIX"])
|
|
97
|
+
offset = no_prefix_size[0] * no_prefix_size[1] * (number_of_bits // 8)
|
|
98
|
+
|
|
99
|
+
prefix = b"Z"
|
|
100
|
+
decoder_name = "fits_gzip"
|
|
101
|
+
|
|
102
|
+
size = self._get_size(headers, prefix)
|
|
103
|
+
if not size:
|
|
104
|
+
return "", 0, ()
|
|
105
|
+
|
|
106
|
+
self._size = size
|
|
107
|
+
|
|
108
|
+
number_of_bits = int(headers[prefix + b"BITPIX"])
|
|
109
|
+
if number_of_bits == 8:
|
|
110
|
+
self._mode = "L"
|
|
111
|
+
elif number_of_bits == 16:
|
|
112
|
+
self._mode = "I;16"
|
|
113
|
+
elif number_of_bits == 32:
|
|
114
|
+
self._mode = "I"
|
|
115
|
+
elif number_of_bits in (-32, -64):
|
|
116
|
+
self._mode = "F"
|
|
117
|
+
|
|
118
|
+
args: tuple[str | int, ...]
|
|
119
|
+
if decoder_name == "raw":
|
|
120
|
+
args = (self.mode, 0, -1)
|
|
121
|
+
else:
|
|
122
|
+
args = (number_of_bits,)
|
|
123
|
+
return decoder_name, offset, args
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class FitsGzipDecoder(ImageFile.PyDecoder):
|
|
127
|
+
_pulls_fd = True
|
|
128
|
+
|
|
129
|
+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
|
|
130
|
+
assert self.fd is not None
|
|
131
|
+
with gzip.open(self.fd) as fp:
|
|
132
|
+
value = fp.read(self.state.xsize * self.state.ysize * 4)
|
|
133
|
+
|
|
134
|
+
rows = []
|
|
135
|
+
offset = 0
|
|
136
|
+
number_of_bits = min(self.args[0] // 8, 4)
|
|
137
|
+
for y in range(self.state.ysize):
|
|
138
|
+
row = bytearray()
|
|
139
|
+
for x in range(self.state.xsize):
|
|
140
|
+
row += value[offset + (4 - number_of_bits) : offset + 4]
|
|
141
|
+
offset += 4
|
|
142
|
+
rows.append(row)
|
|
143
|
+
self.set_as_raw(bytes([pixel for row in rows[::-1] for pixel in row]))
|
|
144
|
+
return -1, 0
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# --------------------------------------------------------------------
|
|
148
|
+
# Registry
|
|
149
|
+
|
|
150
|
+
Image.register_open(FitsImageFile.format, FitsImageFile, _accept)
|
|
151
|
+
Image.register_decoder("fits_gzip", FitsGzipDecoder)
|
|
152
|
+
|
|
153
|
+
Image.register_extensions(FitsImageFile.format, [".fit", ".fits"])
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# FLI/FLC file handling.
|
|
6
|
+
#
|
|
7
|
+
# History:
|
|
8
|
+
# 95-09-01 fl Created
|
|
9
|
+
# 97-01-03 fl Fixed parser, setup decoder tile
|
|
10
|
+
# 98-07-15 fl Renamed offset attribute to avoid name clash
|
|
11
|
+
#
|
|
12
|
+
# Copyright (c) Secret Labs AB 1997-98.
|
|
13
|
+
# Copyright (c) Fredrik Lundh 1995-97.
|
|
14
|
+
#
|
|
15
|
+
# See the README file for information on usage and redistribution.
|
|
16
|
+
#
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
|
|
21
|
+
from . import Image, ImageFile, ImagePalette
|
|
22
|
+
from ._binary import i16le as i16
|
|
23
|
+
from ._binary import i32le as i32
|
|
24
|
+
from ._binary import o8
|
|
25
|
+
from ._util import DeferredError
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
# decoder
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _accept(prefix: bytes) -> bool:
|
|
32
|
+
return (
|
|
33
|
+
len(prefix) >= 16
|
|
34
|
+
and i16(prefix, 4) in [0xAF11, 0xAF12]
|
|
35
|
+
and i16(prefix, 14) in [0, 3] # flags
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# Image plugin for the FLI/FLC animation format. Use the <b>seek</b>
|
|
41
|
+
# method to load individual frames.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class FliImageFile(ImageFile.ImageFile):
|
|
45
|
+
format = "FLI"
|
|
46
|
+
format_description = "Autodesk FLI/FLC Animation"
|
|
47
|
+
_close_exclusive_fp_after_loading = False
|
|
48
|
+
|
|
49
|
+
def _open(self) -> None:
|
|
50
|
+
# HEAD
|
|
51
|
+
assert self.fp is not None
|
|
52
|
+
s = self.fp.read(128)
|
|
53
|
+
if not (
|
|
54
|
+
_accept(s)
|
|
55
|
+
and s[20:22] == b"\x00" * 2
|
|
56
|
+
and s[42:80] == b"\x00" * 38
|
|
57
|
+
and s[88:] == b"\x00" * 40
|
|
58
|
+
):
|
|
59
|
+
msg = "not an FLI/FLC file"
|
|
60
|
+
raise SyntaxError(msg)
|
|
61
|
+
|
|
62
|
+
# frames
|
|
63
|
+
self.n_frames = i16(s, 6)
|
|
64
|
+
self.is_animated = self.n_frames > 1
|
|
65
|
+
|
|
66
|
+
# image characteristics
|
|
67
|
+
self._mode = "P"
|
|
68
|
+
self._size = i16(s, 8), i16(s, 10)
|
|
69
|
+
|
|
70
|
+
# animation speed
|
|
71
|
+
duration = i32(s, 16)
|
|
72
|
+
magic = i16(s, 4)
|
|
73
|
+
if magic == 0xAF11:
|
|
74
|
+
duration = (duration * 1000) // 70
|
|
75
|
+
self.info["duration"] = duration
|
|
76
|
+
|
|
77
|
+
# look for palette
|
|
78
|
+
palette = [(a, a, a) for a in range(256)]
|
|
79
|
+
|
|
80
|
+
s = self.fp.read(16)
|
|
81
|
+
|
|
82
|
+
self.__offset = 128
|
|
83
|
+
|
|
84
|
+
if i16(s, 4) == 0xF100:
|
|
85
|
+
# prefix chunk; ignore it
|
|
86
|
+
self.fp.seek(self.__offset + i32(s))
|
|
87
|
+
s = self.fp.read(16)
|
|
88
|
+
|
|
89
|
+
if i16(s, 4) == 0xF1FA:
|
|
90
|
+
# look for palette chunk
|
|
91
|
+
number_of_subchunks = i16(s, 6)
|
|
92
|
+
chunk_size: int | None = None
|
|
93
|
+
for _ in range(number_of_subchunks):
|
|
94
|
+
if chunk_size is not None:
|
|
95
|
+
self.fp.seek(chunk_size - 6, os.SEEK_CUR)
|
|
96
|
+
s = self.fp.read(6)
|
|
97
|
+
chunk_type = i16(s, 4)
|
|
98
|
+
if chunk_type in (4, 11):
|
|
99
|
+
self._palette(palette, 2 if chunk_type == 11 else 0)
|
|
100
|
+
break
|
|
101
|
+
chunk_size = i32(s)
|
|
102
|
+
if not chunk_size:
|
|
103
|
+
break
|
|
104
|
+
|
|
105
|
+
self.palette = ImagePalette.raw(
|
|
106
|
+
"RGB", b"".join(o8(r) + o8(g) + o8(b) for (r, g, b) in palette)
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# set things up to decode first frame
|
|
110
|
+
self.__frame = -1
|
|
111
|
+
self._fp = self.fp
|
|
112
|
+
self.__rewind = self.fp.tell()
|
|
113
|
+
self.seek(0)
|
|
114
|
+
|
|
115
|
+
def _palette(self, palette: list[tuple[int, int, int]], shift: int) -> None:
|
|
116
|
+
# load palette
|
|
117
|
+
|
|
118
|
+
i = 0
|
|
119
|
+
assert self.fp is not None
|
|
120
|
+
for e in range(i16(self.fp.read(2))):
|
|
121
|
+
s = self.fp.read(2)
|
|
122
|
+
i = i + s[0]
|
|
123
|
+
n = s[1]
|
|
124
|
+
if n == 0:
|
|
125
|
+
n = 256
|
|
126
|
+
s = self.fp.read(n * 3)
|
|
127
|
+
for n in range(0, len(s), 3):
|
|
128
|
+
r = s[n] << shift
|
|
129
|
+
g = s[n + 1] << shift
|
|
130
|
+
b = s[n + 2] << shift
|
|
131
|
+
palette[i] = (r, g, b)
|
|
132
|
+
i += 1
|
|
133
|
+
|
|
134
|
+
def seek(self, frame: int) -> None:
|
|
135
|
+
if not self._seek_check(frame):
|
|
136
|
+
return
|
|
137
|
+
if frame < self.__frame:
|
|
138
|
+
self._seek(0)
|
|
139
|
+
|
|
140
|
+
for f in range(self.__frame + 1, frame + 1):
|
|
141
|
+
self._seek(f)
|
|
142
|
+
|
|
143
|
+
def _seek(self, frame: int) -> None:
|
|
144
|
+
if isinstance(self._fp, DeferredError):
|
|
145
|
+
raise self._fp.ex
|
|
146
|
+
if frame == 0:
|
|
147
|
+
self.__frame = -1
|
|
148
|
+
self._fp.seek(self.__rewind)
|
|
149
|
+
self.__offset = 128
|
|
150
|
+
else:
|
|
151
|
+
# ensure that the previous frame was loaded
|
|
152
|
+
self.load()
|
|
153
|
+
|
|
154
|
+
if frame != self.__frame + 1:
|
|
155
|
+
msg = f"cannot seek to frame {frame}"
|
|
156
|
+
raise ValueError(msg)
|
|
157
|
+
self.__frame = frame
|
|
158
|
+
|
|
159
|
+
# move to next frame
|
|
160
|
+
self.fp = self._fp
|
|
161
|
+
self.fp.seek(self.__offset)
|
|
162
|
+
|
|
163
|
+
s = self.fp.read(4)
|
|
164
|
+
if not s:
|
|
165
|
+
msg = "missing frame size"
|
|
166
|
+
raise EOFError(msg)
|
|
167
|
+
|
|
168
|
+
framesize = i32(s)
|
|
169
|
+
|
|
170
|
+
self.decodermaxblock = framesize
|
|
171
|
+
self.tile = [ImageFile._Tile("fli", (0, 0) + self.size, self.__offset)]
|
|
172
|
+
|
|
173
|
+
self.__offset += framesize
|
|
174
|
+
|
|
175
|
+
def tell(self) -> int:
|
|
176
|
+
return self.__frame
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
#
|
|
180
|
+
# registry
|
|
181
|
+
|
|
182
|
+
Image.register_open(FliImageFile.format, FliImageFile, _accept)
|
|
183
|
+
|
|
184
|
+
Image.register_extensions(FliImageFile.format, [".fli", ".flc"])
|