Spaces:
Runtime error
Runtime error
Commit
·
435481f
1
Parent(s):
61faed6
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +62 -0
- .idea/.gitignore +3 -0
- .idea/ImageColorizerDeployment.iml +10 -0
- .idea/dbnavigator.xml +459 -0
- .idea/inspectionProfiles/Project_Default.xml +56 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/workspace.xml +47 -0
- README.md +1 -7
- app.py +22 -0
- landColorGenV1.keras +3 -0
- venv/.gitignore +2 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/INSTALLER +1 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst +28 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/METADATA +113 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/RECORD +58 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/WHEEL +5 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/entry_points.txt +2 -0
- venv/Lib/site-packages/Jinja2-3.1.2.dist-info/top_level.txt +1 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/INSTALLER +1 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/LICENSE.md +29 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/METADATA +145 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/RECORD +74 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/WHEEL +5 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/entry_points.txt +22 -0
- venv/Lib/site-packages/Markdown-3.5.dist-info/top_level.txt +1 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/INSTALLER +1 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/LICENSE.rst +28 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/METADATA +93 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/RECORD +14 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/WHEEL +5 -0
- venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/top_level.txt +1 -0
- venv/Lib/site-packages/PIL/BdfFontFile.py +122 -0
- venv/Lib/site-packages/PIL/BlpImagePlugin.py +474 -0
- venv/Lib/site-packages/PIL/BmpImagePlugin.py +471 -0
- venv/Lib/site-packages/PIL/BufrStubImagePlugin.py +73 -0
- venv/Lib/site-packages/PIL/ContainerIO.py +120 -0
- venv/Lib/site-packages/PIL/CurImagePlugin.py +75 -0
- venv/Lib/site-packages/PIL/DcxImagePlugin.py +79 -0
- venv/Lib/site-packages/PIL/DdsImagePlugin.py +295 -0
- venv/Lib/site-packages/PIL/EpsImagePlugin.py +480 -0
- venv/Lib/site-packages/PIL/ExifTags.py +380 -0
- venv/Lib/site-packages/PIL/FitsImagePlugin.py +73 -0
- venv/Lib/site-packages/PIL/FliImagePlugin.py +171 -0
- venv/Lib/site-packages/PIL/FontFile.py +110 -0
- venv/Lib/site-packages/PIL/FpxImagePlugin.py +253 -0
- venv/Lib/site-packages/PIL/FtexImagePlugin.py +113 -0
- venv/Lib/site-packages/PIL/GbrImagePlugin.py +102 -0
- venv/Lib/site-packages/PIL/GdImageFile.py +97 -0
.gitattributes
CHANGED
@@ -33,3 +33,65 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
landColorGenV1.keras filter=lfs diff=lfs merge=lfs -text
|
37 |
+
venv/Lib/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-38.pyc filter=lfs diff=lfs merge=lfs -text
|
38 |
+
venv/Lib/site-packages/clang/native/libclang.dll filter=lfs diff=lfs merge=lfs -text
|
39 |
+
venv/Lib/site-packages/gradio/templates/cdn/assets/index-973aa9f2.js.map filter=lfs diff=lfs merge=lfs -text
|
40 |
+
venv/Lib/site-packages/gradio/templates/frontend/assets/index-397dd2f4.js.map filter=lfs diff=lfs merge=lfs -text
|
41 |
+
venv/Lib/site-packages/grpc/_cython/cygrpc.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
42 |
+
venv/Lib/site-packages/h5py/hdf5.dll filter=lfs diff=lfs merge=lfs -text
|
43 |
+
venv/Lib/site-packages/numpy/.libs/libopenblas64__v0.3.21-gcc_10_3_0.dll filter=lfs diff=lfs merge=lfs -text
|
44 |
+
venv/Lib/site-packages/numpy/core/_multiarray_umath.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
45 |
+
venv/Lib/site-packages/numpy/core/_simd.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
46 |
+
venv/Lib/site-packages/pandas/_libs/algos.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
47 |
+
venv/Lib/site-packages/pandas/_libs/groupby.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
48 |
+
venv/Lib/site-packages/pandas/_libs/hashtable.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
49 |
+
venv/Lib/site-packages/pandas/_libs/join.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
50 |
+
venv/Lib/site-packages/PIL/_imaging.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
51 |
+
venv/Lib/site-packages/PIL/_imagingft.cp38-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
52 |
+
venv/Lib/site-packages/tensorflow/compiler/tf2tensorrt/_pywrap_py_utils.pyd filter=lfs diff=lfs merge=lfs -text
|
53 |
+
venv/Lib/site-packages/tensorflow/compiler/tf2xla/ops/_xla_ops.so filter=lfs diff=lfs merge=lfs -text
|
54 |
+
venv/Lib/site-packages/tensorflow/lite/python/interpreter_wrapper/_pywrap_tensorflow_interpreter_wrapper.pyd filter=lfs diff=lfs merge=lfs -text
|
55 |
+
venv/Lib/site-packages/tensorflow/lite/python/metrics/_pywrap_tensorflow_lite_metrics_wrapper.pyd filter=lfs diff=lfs merge=lfs -text
|
56 |
+
venv/Lib/site-packages/tensorflow/lite/python/optimize/_pywrap_tensorflow_lite_calibration_wrapper.pyd filter=lfs diff=lfs merge=lfs -text
|
57 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_dtensor_device.pyd filter=lfs diff=lfs merge=lfs -text
|
58 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_mlir.pyd filter=lfs diff=lfs merge=lfs -text
|
59 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_parallel_device.pyd filter=lfs diff=lfs merge=lfs -text
|
60 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_quantize_training.pyd filter=lfs diff=lfs merge=lfs -text
|
61 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_tensorflow_internal.lib filter=lfs diff=lfs merge=lfs -text
|
62 |
+
venv/Lib/site-packages/tensorflow/python/_pywrap_tensorflow_internal.pyd filter=lfs diff=lfs merge=lfs -text
|
63 |
+
venv/Lib/site-packages/tensorflow/python/bfloat16.so filter=lfs diff=lfs merge=lfs -text
|
64 |
+
venv/Lib/site-packages/tensorflow/python/client/_pywrap_debug_events_writer.pyd filter=lfs diff=lfs merge=lfs -text
|
65 |
+
venv/Lib/site-packages/tensorflow/python/client/_pywrap_device_lib.pyd filter=lfs diff=lfs merge=lfs -text
|
66 |
+
venv/Lib/site-packages/tensorflow/python/client/_pywrap_events_writer.pyd filter=lfs diff=lfs merge=lfs -text
|
67 |
+
venv/Lib/site-packages/tensorflow/python/client/_pywrap_tf_session.pyd filter=lfs diff=lfs merge=lfs -text
|
68 |
+
venv/Lib/site-packages/tensorflow/python/data/experimental/service/_pywrap_server_lib.pyd filter=lfs diff=lfs merge=lfs -text
|
69 |
+
venv/Lib/site-packages/tensorflow/python/data/experimental/service/_pywrap_utils.pyd filter=lfs diff=lfs merge=lfs -text
|
70 |
+
venv/Lib/site-packages/tensorflow/python/flags_pybind.pyd filter=lfs diff=lfs merge=lfs -text
|
71 |
+
venv/Lib/site-packages/tensorflow/python/framework/_dtypes.pyd filter=lfs diff=lfs merge=lfs -text
|
72 |
+
venv/Lib/site-packages/tensorflow/python/framework/_errors_test_helper.pyd filter=lfs diff=lfs merge=lfs -text
|
73 |
+
venv/Lib/site-packages/tensorflow/python/framework/_op_def_library_pybind.pyd filter=lfs diff=lfs merge=lfs -text
|
74 |
+
venv/Lib/site-packages/tensorflow/python/framework/_op_def_registry.pyd filter=lfs diff=lfs merge=lfs -text
|
75 |
+
venv/Lib/site-packages/tensorflow/python/framework/_op_def_util.pyd filter=lfs diff=lfs merge=lfs -text
|
76 |
+
venv/Lib/site-packages/tensorflow/python/framework/_proto_comparators.pyd filter=lfs diff=lfs merge=lfs -text
|
77 |
+
venv/Lib/site-packages/tensorflow/python/framework/_pywrap_python_api_info.pyd filter=lfs diff=lfs merge=lfs -text
|
78 |
+
venv/Lib/site-packages/tensorflow/python/framework/_pywrap_python_api_parameter_converter.pyd filter=lfs diff=lfs merge=lfs -text
|
79 |
+
venv/Lib/site-packages/tensorflow/python/framework/_pywrap_python_op_gen.pyd filter=lfs diff=lfs merge=lfs -text
|
80 |
+
venv/Lib/site-packages/tensorflow/python/framework/_test_metrics_util.pyd filter=lfs diff=lfs merge=lfs -text
|
81 |
+
venv/Lib/site-packages/tensorflow/python/grappler/_pywrap_tf_cluster.pyd filter=lfs diff=lfs merge=lfs -text
|
82 |
+
venv/Lib/site-packages/tensorflow/python/grappler/_pywrap_tf_item.pyd filter=lfs diff=lfs merge=lfs -text
|
83 |
+
venv/Lib/site-packages/tensorflow/python/grappler/_pywrap_tf_optimizer.pyd filter=lfs diff=lfs merge=lfs -text
|
84 |
+
venv/Lib/site-packages/tensorflow/python/lib/io/_pywrap_file_io.pyd filter=lfs diff=lfs merge=lfs -text
|
85 |
+
venv/Lib/site-packages/tensorflow/python/lib/io/_pywrap_record_io.pyd filter=lfs diff=lfs merge=lfs -text
|
86 |
+
venv/Lib/site-packages/tensorflow/python/platform/_pywrap_tf2.pyd filter=lfs diff=lfs merge=lfs -text
|
87 |
+
venv/Lib/site-packages/tensorflow/python/profiler/internal/_pywrap_profiler.pyd filter=lfs diff=lfs merge=lfs -text
|
88 |
+
venv/Lib/site-packages/tensorflow/python/saved_model/pywrap_saved_model.pyd filter=lfs diff=lfs merge=lfs -text
|
89 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_checkpoint_reader.pyd filter=lfs diff=lfs merge=lfs -text
|
90 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_kernel_registry.pyd filter=lfs diff=lfs merge=lfs -text
|
91 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_stat_summarizer.pyd filter=lfs diff=lfs merge=lfs -text
|
92 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_tfprof.pyd filter=lfs diff=lfs merge=lfs -text
|
93 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_transform_graph.pyd filter=lfs diff=lfs merge=lfs -text
|
94 |
+
venv/Lib/site-packages/tensorflow/python/util/_pywrap_util_port.pyd filter=lfs diff=lfs merge=lfs -text
|
95 |
+
venv/Lib/site-packages/tensorflow/python/util/_tf_stack.pyd filter=lfs diff=lfs merge=lfs -text
|
96 |
+
venv/Lib/site-packages/tensorflow/tsl/python/lib/core/bfloat16.so filter=lfs diff=lfs merge=lfs -text
|
97 |
+
venv/Lib/site-packages/tensorflow_io_gcs_filesystem/core/python/ops/libtensorflow_io_gcs_filesystem.so filter=lfs diff=lfs merge=lfs -text
|
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/ImageColorizerDeployment.iml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
6 |
+
</content>
|
7 |
+
<orderEntry type="inheritedJdk" />
|
8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
+
</component>
|
10 |
+
</module>
|
.idea/dbnavigator.xml
ADDED
@@ -0,0 +1,459 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="DBNavigator.Project.DataEditorManager">
|
4 |
+
<record-view-column-sorting-type value="BY_INDEX" />
|
5 |
+
<value-preview-text-wrapping value="true" />
|
6 |
+
<value-preview-pinned value="false" />
|
7 |
+
</component>
|
8 |
+
<component name="DBNavigator.Project.DataExportManager">
|
9 |
+
<export-instructions>
|
10 |
+
<create-header value="true" />
|
11 |
+
<friendly-headers value="false" />
|
12 |
+
<quote-values-containing-separator value="true" />
|
13 |
+
<quote-all-values value="false" />
|
14 |
+
<value-separator value="" />
|
15 |
+
<file-name value="" />
|
16 |
+
<file-location value="" />
|
17 |
+
<scope value="GLOBAL" />
|
18 |
+
<destination value="FILE" />
|
19 |
+
<format value="EXCEL" />
|
20 |
+
<charset value="windows-1252" />
|
21 |
+
<charset value="windows-1252" />
|
22 |
+
</export-instructions>
|
23 |
+
</component>
|
24 |
+
<component name="DBNavigator.Project.DatabaseBrowserManager">
|
25 |
+
<autoscroll-to-editor value="false" />
|
26 |
+
<autoscroll-from-editor value="true" />
|
27 |
+
<show-object-properties value="true" />
|
28 |
+
<loaded-nodes />
|
29 |
+
</component>
|
30 |
+
<component name="DBNavigator.Project.DatabaseFileManager">
|
31 |
+
<open-files />
|
32 |
+
</component>
|
33 |
+
<component name="DBNavigator.Project.EditorStateManager">
|
34 |
+
<last-used-providers />
|
35 |
+
</component>
|
36 |
+
<component name="DBNavigator.Project.ExecutionManager">
|
37 |
+
<retain-sticky-names value="false" />
|
38 |
+
</component>
|
39 |
+
<component name="DBNavigator.Project.MethodExecutionManager">
|
40 |
+
<method-browser />
|
41 |
+
<execution-history>
|
42 |
+
<group-entries value="true" />
|
43 |
+
<execution-inputs />
|
44 |
+
</execution-history>
|
45 |
+
<argument-values-cache />
|
46 |
+
</component>
|
47 |
+
<component name="DBNavigator.Project.ObjectDependencyManager">
|
48 |
+
<last-used-dependency-type value="INCOMING" />
|
49 |
+
</component>
|
50 |
+
<component name="DBNavigator.Project.ObjectQuickFilterManager">
|
51 |
+
<last-used-operator value="EQUAL" />
|
52 |
+
<filters />
|
53 |
+
</component>
|
54 |
+
<component name="DBNavigator.Project.ParserDiagnosticsManager">
|
55 |
+
<diagnostics-history />
|
56 |
+
</component>
|
57 |
+
<component name="DBNavigator.Project.ScriptExecutionManager" clear-outputs="true">
|
58 |
+
<recently-used-interfaces />
|
59 |
+
</component>
|
60 |
+
<component name="DBNavigator.Project.Settings">
|
61 |
+
<connections />
|
62 |
+
<browser-settings>
|
63 |
+
<general>
|
64 |
+
<display-mode value="TABBED" />
|
65 |
+
<navigation-history-size value="100" />
|
66 |
+
<show-object-details value="false" />
|
67 |
+
</general>
|
68 |
+
<filters>
|
69 |
+
<object-type-filter>
|
70 |
+
<object-type name="SCHEMA" enabled="true" />
|
71 |
+
<object-type name="USER" enabled="true" />
|
72 |
+
<object-type name="ROLE" enabled="true" />
|
73 |
+
<object-type name="PRIVILEGE" enabled="true" />
|
74 |
+
<object-type name="CHARSET" enabled="true" />
|
75 |
+
<object-type name="TABLE" enabled="true" />
|
76 |
+
<object-type name="VIEW" enabled="true" />
|
77 |
+
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
78 |
+
<object-type name="NESTED_TABLE" enabled="true" />
|
79 |
+
<object-type name="COLUMN" enabled="true" />
|
80 |
+
<object-type name="INDEX" enabled="true" />
|
81 |
+
<object-type name="CONSTRAINT" enabled="true" />
|
82 |
+
<object-type name="DATASET_TRIGGER" enabled="true" />
|
83 |
+
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
84 |
+
<object-type name="SYNONYM" enabled="true" />
|
85 |
+
<object-type name="SEQUENCE" enabled="true" />
|
86 |
+
<object-type name="PROCEDURE" enabled="true" />
|
87 |
+
<object-type name="FUNCTION" enabled="true" />
|
88 |
+
<object-type name="PACKAGE" enabled="true" />
|
89 |
+
<object-type name="TYPE" enabled="true" />
|
90 |
+
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
91 |
+
<object-type name="ARGUMENT" enabled="true" />
|
92 |
+
<object-type name="DIMENSION" enabled="true" />
|
93 |
+
<object-type name="CLUSTER" enabled="true" />
|
94 |
+
<object-type name="DBLINK" enabled="true" />
|
95 |
+
</object-type-filter>
|
96 |
+
</filters>
|
97 |
+
<sorting>
|
98 |
+
<object-type name="COLUMN" sorting-type="NAME" />
|
99 |
+
<object-type name="FUNCTION" sorting-type="NAME" />
|
100 |
+
<object-type name="PROCEDURE" sorting-type="NAME" />
|
101 |
+
<object-type name="ARGUMENT" sorting-type="POSITION" />
|
102 |
+
<object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" />
|
103 |
+
</sorting>
|
104 |
+
<default-editors>
|
105 |
+
<object-type name="VIEW" editor-type="SELECTION" />
|
106 |
+
<object-type name="PACKAGE" editor-type="SELECTION" />
|
107 |
+
<object-type name="TYPE" editor-type="SELECTION" />
|
108 |
+
</default-editors>
|
109 |
+
</browser-settings>
|
110 |
+
<navigation-settings>
|
111 |
+
<lookup-filters>
|
112 |
+
<lookup-objects>
|
113 |
+
<object-type name="SCHEMA" enabled="true" />
|
114 |
+
<object-type name="USER" enabled="false" />
|
115 |
+
<object-type name="ROLE" enabled="false" />
|
116 |
+
<object-type name="PRIVILEGE" enabled="false" />
|
117 |
+
<object-type name="CHARSET" enabled="false" />
|
118 |
+
<object-type name="TABLE" enabled="true" />
|
119 |
+
<object-type name="VIEW" enabled="true" />
|
120 |
+
<object-type name="MATERIALIZED VIEW" enabled="true" />
|
121 |
+
<object-type name="INDEX" enabled="true" />
|
122 |
+
<object-type name="CONSTRAINT" enabled="true" />
|
123 |
+
<object-type name="DATASET TRIGGER" enabled="true" />
|
124 |
+
<object-type name="DATABASE TRIGGER" enabled="true" />
|
125 |
+
<object-type name="SYNONYM" enabled="false" />
|
126 |
+
<object-type name="SEQUENCE" enabled="true" />
|
127 |
+
<object-type name="PROCEDURE" enabled="true" />
|
128 |
+
<object-type name="FUNCTION" enabled="true" />
|
129 |
+
<object-type name="PACKAGE" enabled="true" />
|
130 |
+
<object-type name="TYPE" enabled="true" />
|
131 |
+
<object-type name="DIMENSION" enabled="false" />
|
132 |
+
<object-type name="CLUSTER" enabled="false" />
|
133 |
+
<object-type name="DBLINK" enabled="true" />
|
134 |
+
</lookup-objects>
|
135 |
+
<force-database-load value="false" />
|
136 |
+
<prompt-connection-selection value="true" />
|
137 |
+
<prompt-schema-selection value="true" />
|
138 |
+
</lookup-filters>
|
139 |
+
</navigation-settings>
|
140 |
+
<dataset-grid-settings>
|
141 |
+
<general>
|
142 |
+
<enable-zooming value="true" />
|
143 |
+
<enable-column-tooltip value="true" />
|
144 |
+
</general>
|
145 |
+
<sorting>
|
146 |
+
<nulls-first value="true" />
|
147 |
+
<max-sorting-columns value="4" />
|
148 |
+
</sorting>
|
149 |
+
<audit-columns>
|
150 |
+
<column-names value="" />
|
151 |
+
<visible value="true" />
|
152 |
+
<editable value="false" />
|
153 |
+
</audit-columns>
|
154 |
+
</dataset-grid-settings>
|
155 |
+
<dataset-editor-settings>
|
156 |
+
<text-editor-popup>
|
157 |
+
<active value="false" />
|
158 |
+
<active-if-empty value="false" />
|
159 |
+
<data-length-threshold value="100" />
|
160 |
+
<popup-delay value="1000" />
|
161 |
+
</text-editor-popup>
|
162 |
+
<values-actions-popup>
|
163 |
+
<show-popup-button value="true" />
|
164 |
+
<element-count-threshold value="1000" />
|
165 |
+
<data-length-threshold value="250" />
|
166 |
+
</values-actions-popup>
|
167 |
+
<general>
|
168 |
+
<fetch-block-size value="100" />
|
169 |
+
<fetch-timeout value="30" />
|
170 |
+
<trim-whitespaces value="true" />
|
171 |
+
<convert-empty-strings-to-null value="true" />
|
172 |
+
<select-content-on-cell-edit value="true" />
|
173 |
+
<large-value-preview-active value="true" />
|
174 |
+
</general>
|
175 |
+
<filters>
|
176 |
+
<prompt-filter-dialog value="true" />
|
177 |
+
<default-filter-type value="BASIC" />
|
178 |
+
</filters>
|
179 |
+
<qualified-text-editor text-length-threshold="300">
|
180 |
+
<content-types>
|
181 |
+
<content-type name="Text" enabled="true" />
|
182 |
+
<content-type name="Properties" enabled="true" />
|
183 |
+
<content-type name="XML" enabled="true" />
|
184 |
+
<content-type name="DTD" enabled="true" />
|
185 |
+
<content-type name="HTML" enabled="true" />
|
186 |
+
<content-type name="XHTML" enabled="true" />
|
187 |
+
<content-type name="SQL" enabled="true" />
|
188 |
+
<content-type name="PL/SQL" enabled="true" />
|
189 |
+
<content-type name="JSON" enabled="true" />
|
190 |
+
<content-type name="JSON5" enabled="true" />
|
191 |
+
<content-type name="YAML" enabled="true" />
|
192 |
+
</content-types>
|
193 |
+
</qualified-text-editor>
|
194 |
+
<record-navigation>
|
195 |
+
<navigation-target value="VIEWER" />
|
196 |
+
</record-navigation>
|
197 |
+
</dataset-editor-settings>
|
198 |
+
<code-editor-settings>
|
199 |
+
<general>
|
200 |
+
<show-object-navigation-gutter value="false" />
|
201 |
+
<show-spec-declaration-navigation-gutter value="true" />
|
202 |
+
<enable-spellchecking value="true" />
|
203 |
+
<enable-reference-spellchecking value="false" />
|
204 |
+
</general>
|
205 |
+
<confirmations>
|
206 |
+
<save-changes value="false" />
|
207 |
+
<revert-changes value="true" />
|
208 |
+
</confirmations>
|
209 |
+
</code-editor-settings>
|
210 |
+
<code-completion-settings>
|
211 |
+
<filters>
|
212 |
+
<basic-filter>
|
213 |
+
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
214 |
+
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
215 |
+
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
216 |
+
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
217 |
+
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
218 |
+
<filter-element type="OBJECT" id="schema" selected="true" />
|
219 |
+
<filter-element type="OBJECT" id="role" selected="true" />
|
220 |
+
<filter-element type="OBJECT" id="user" selected="true" />
|
221 |
+
<filter-element type="OBJECT" id="privilege" selected="true" />
|
222 |
+
<user-schema>
|
223 |
+
<filter-element type="OBJECT" id="table" selected="true" />
|
224 |
+
<filter-element type="OBJECT" id="view" selected="true" />
|
225 |
+
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
226 |
+
<filter-element type="OBJECT" id="index" selected="true" />
|
227 |
+
<filter-element type="OBJECT" id="constraint" selected="true" />
|
228 |
+
<filter-element type="OBJECT" id="trigger" selected="true" />
|
229 |
+
<filter-element type="OBJECT" id="synonym" selected="false" />
|
230 |
+
<filter-element type="OBJECT" id="sequence" selected="true" />
|
231 |
+
<filter-element type="OBJECT" id="procedure" selected="true" />
|
232 |
+
<filter-element type="OBJECT" id="function" selected="true" />
|
233 |
+
<filter-element type="OBJECT" id="package" selected="true" />
|
234 |
+
<filter-element type="OBJECT" id="type" selected="true" />
|
235 |
+
<filter-element type="OBJECT" id="dimension" selected="true" />
|
236 |
+
<filter-element type="OBJECT" id="cluster" selected="true" />
|
237 |
+
<filter-element type="OBJECT" id="dblink" selected="true" />
|
238 |
+
</user-schema>
|
239 |
+
<public-schema>
|
240 |
+
<filter-element type="OBJECT" id="table" selected="false" />
|
241 |
+
<filter-element type="OBJECT" id="view" selected="false" />
|
242 |
+
<filter-element type="OBJECT" id="materialized view" selected="false" />
|
243 |
+
<filter-element type="OBJECT" id="index" selected="false" />
|
244 |
+
<filter-element type="OBJECT" id="constraint" selected="false" />
|
245 |
+
<filter-element type="OBJECT" id="trigger" selected="false" />
|
246 |
+
<filter-element type="OBJECT" id="synonym" selected="false" />
|
247 |
+
<filter-element type="OBJECT" id="sequence" selected="false" />
|
248 |
+
<filter-element type="OBJECT" id="procedure" selected="false" />
|
249 |
+
<filter-element type="OBJECT" id="function" selected="false" />
|
250 |
+
<filter-element type="OBJECT" id="package" selected="false" />
|
251 |
+
<filter-element type="OBJECT" id="type" selected="false" />
|
252 |
+
<filter-element type="OBJECT" id="dimension" selected="false" />
|
253 |
+
<filter-element type="OBJECT" id="cluster" selected="false" />
|
254 |
+
<filter-element type="OBJECT" id="dblink" selected="false" />
|
255 |
+
</public-schema>
|
256 |
+
<any-schema>
|
257 |
+
<filter-element type="OBJECT" id="table" selected="true" />
|
258 |
+
<filter-element type="OBJECT" id="view" selected="true" />
|
259 |
+
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
260 |
+
<filter-element type="OBJECT" id="index" selected="true" />
|
261 |
+
<filter-element type="OBJECT" id="constraint" selected="true" />
|
262 |
+
<filter-element type="OBJECT" id="trigger" selected="true" />
|
263 |
+
<filter-element type="OBJECT" id="synonym" selected="true" />
|
264 |
+
<filter-element type="OBJECT" id="sequence" selected="true" />
|
265 |
+
<filter-element type="OBJECT" id="procedure" selected="true" />
|
266 |
+
<filter-element type="OBJECT" id="function" selected="true" />
|
267 |
+
<filter-element type="OBJECT" id="package" selected="true" />
|
268 |
+
<filter-element type="OBJECT" id="type" selected="true" />
|
269 |
+
<filter-element type="OBJECT" id="dimension" selected="true" />
|
270 |
+
<filter-element type="OBJECT" id="cluster" selected="true" />
|
271 |
+
<filter-element type="OBJECT" id="dblink" selected="true" />
|
272 |
+
</any-schema>
|
273 |
+
</basic-filter>
|
274 |
+
<extended-filter>
|
275 |
+
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
276 |
+
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
277 |
+
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
278 |
+
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
279 |
+
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
280 |
+
<filter-element type="OBJECT" id="schema" selected="true" />
|
281 |
+
<filter-element type="OBJECT" id="user" selected="true" />
|
282 |
+
<filter-element type="OBJECT" id="role" selected="true" />
|
283 |
+
<filter-element type="OBJECT" id="privilege" selected="true" />
|
284 |
+
<user-schema>
|
285 |
+
<filter-element type="OBJECT" id="table" selected="true" />
|
286 |
+
<filter-element type="OBJECT" id="view" selected="true" />
|
287 |
+
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
288 |
+
<filter-element type="OBJECT" id="index" selected="true" />
|
289 |
+
<filter-element type="OBJECT" id="constraint" selected="true" />
|
290 |
+
<filter-element type="OBJECT" id="trigger" selected="true" />
|
291 |
+
<filter-element type="OBJECT" id="synonym" selected="true" />
|
292 |
+
<filter-element type="OBJECT" id="sequence" selected="true" />
|
293 |
+
<filter-element type="OBJECT" id="procedure" selected="true" />
|
294 |
+
<filter-element type="OBJECT" id="function" selected="true" />
|
295 |
+
<filter-element type="OBJECT" id="package" selected="true" />
|
296 |
+
<filter-element type="OBJECT" id="type" selected="true" />
|
297 |
+
<filter-element type="OBJECT" id="dimension" selected="true" />
|
298 |
+
<filter-element type="OBJECT" id="cluster" selected="true" />
|
299 |
+
<filter-element type="OBJECT" id="dblink" selected="true" />
|
300 |
+
</user-schema>
|
301 |
+
<public-schema>
|
302 |
+
<filter-element type="OBJECT" id="table" selected="true" />
|
303 |
+
<filter-element type="OBJECT" id="view" selected="true" />
|
304 |
+
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
305 |
+
<filter-element type="OBJECT" id="index" selected="true" />
|
306 |
+
<filter-element type="OBJECT" id="constraint" selected="true" />
|
307 |
+
<filter-element type="OBJECT" id="trigger" selected="true" />
|
308 |
+
<filter-element type="OBJECT" id="synonym" selected="true" />
|
309 |
+
<filter-element type="OBJECT" id="sequence" selected="true" />
|
310 |
+
<filter-element type="OBJECT" id="procedure" selected="true" />
|
311 |
+
<filter-element type="OBJECT" id="function" selected="true" />
|
312 |
+
<filter-element type="OBJECT" id="package" selected="true" />
|
313 |
+
<filter-element type="OBJECT" id="type" selected="true" />
|
314 |
+
<filter-element type="OBJECT" id="dimension" selected="true" />
|
315 |
+
<filter-element type="OBJECT" id="cluster" selected="true" />
|
316 |
+
<filter-element type="OBJECT" id="dblink" selected="true" />
|
317 |
+
</public-schema>
|
318 |
+
<any-schema>
|
319 |
+
<filter-element type="OBJECT" id="table" selected="true" />
|
320 |
+
<filter-element type="OBJECT" id="view" selected="true" />
|
321 |
+
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
322 |
+
<filter-element type="OBJECT" id="index" selected="true" />
|
323 |
+
<filter-element type="OBJECT" id="constraint" selected="true" />
|
324 |
+
<filter-element type="OBJECT" id="trigger" selected="true" />
|
325 |
+
<filter-element type="OBJECT" id="synonym" selected="true" />
|
326 |
+
<filter-element type="OBJECT" id="sequence" selected="true" />
|
327 |
+
<filter-element type="OBJECT" id="procedure" selected="true" />
|
328 |
+
<filter-element type="OBJECT" id="function" selected="true" />
|
329 |
+
<filter-element type="OBJECT" id="package" selected="true" />
|
330 |
+
<filter-element type="OBJECT" id="type" selected="true" />
|
331 |
+
<filter-element type="OBJECT" id="dimension" selected="true" />
|
332 |
+
<filter-element type="OBJECT" id="cluster" selected="true" />
|
333 |
+
<filter-element type="OBJECT" id="dblink" selected="true" />
|
334 |
+
</any-schema>
|
335 |
+
</extended-filter>
|
336 |
+
</filters>
|
337 |
+
<sorting enabled="true">
|
338 |
+
<sorting-element type="RESERVED_WORD" id="keyword" />
|
339 |
+
<sorting-element type="RESERVED_WORD" id="datatype" />
|
340 |
+
<sorting-element type="OBJECT" id="column" />
|
341 |
+
<sorting-element type="OBJECT" id="table" />
|
342 |
+
<sorting-element type="OBJECT" id="view" />
|
343 |
+
<sorting-element type="OBJECT" id="materialized view" />
|
344 |
+
<sorting-element type="OBJECT" id="index" />
|
345 |
+
<sorting-element type="OBJECT" id="constraint" />
|
346 |
+
<sorting-element type="OBJECT" id="trigger" />
|
347 |
+
<sorting-element type="OBJECT" id="synonym" />
|
348 |
+
<sorting-element type="OBJECT" id="sequence" />
|
349 |
+
<sorting-element type="OBJECT" id="procedure" />
|
350 |
+
<sorting-element type="OBJECT" id="function" />
|
351 |
+
<sorting-element type="OBJECT" id="package" />
|
352 |
+
<sorting-element type="OBJECT" id="type" />
|
353 |
+
<sorting-element type="OBJECT" id="dimension" />
|
354 |
+
<sorting-element type="OBJECT" id="cluster" />
|
355 |
+
<sorting-element type="OBJECT" id="dblink" />
|
356 |
+
<sorting-element type="OBJECT" id="schema" />
|
357 |
+
<sorting-element type="OBJECT" id="role" />
|
358 |
+
<sorting-element type="OBJECT" id="user" />
|
359 |
+
<sorting-element type="RESERVED_WORD" id="function" />
|
360 |
+
<sorting-element type="RESERVED_WORD" id="parameter" />
|
361 |
+
</sorting>
|
362 |
+
<format>
|
363 |
+
<enforce-code-style-case value="true" />
|
364 |
+
</format>
|
365 |
+
</code-completion-settings>
|
366 |
+
<execution-engine-settings>
|
367 |
+
<statement-execution>
|
368 |
+
<fetch-block-size value="100" />
|
369 |
+
<execution-timeout value="20" />
|
370 |
+
<debug-execution-timeout value="600" />
|
371 |
+
<focus-result value="false" />
|
372 |
+
<prompt-execution value="false" />
|
373 |
+
</statement-execution>
|
374 |
+
<script-execution>
|
375 |
+
<command-line-interfaces />
|
376 |
+
<execution-timeout value="300" />
|
377 |
+
</script-execution>
|
378 |
+
<method-execution>
|
379 |
+
<execution-timeout value="30" />
|
380 |
+
<debug-execution-timeout value="600" />
|
381 |
+
<parameter-history-size value="10" />
|
382 |
+
</method-execution>
|
383 |
+
</execution-engine-settings>
|
384 |
+
<operation-settings>
|
385 |
+
<transactions>
|
386 |
+
<uncommitted-changes>
|
387 |
+
<on-project-close value="ASK" />
|
388 |
+
<on-disconnect value="ASK" />
|
389 |
+
<on-autocommit-toggle value="ASK" />
|
390 |
+
</uncommitted-changes>
|
391 |
+
<multiple-uncommitted-changes>
|
392 |
+
<on-commit value="ASK" />
|
393 |
+
<on-rollback value="ASK" />
|
394 |
+
</multiple-uncommitted-changes>
|
395 |
+
</transactions>
|
396 |
+
<session-browser>
|
397 |
+
<disconnect-session value="ASK" />
|
398 |
+
<kill-session value="ASK" />
|
399 |
+
<reload-on-filter-change value="false" />
|
400 |
+
</session-browser>
|
401 |
+
<compiler>
|
402 |
+
<compile-type value="KEEP" />
|
403 |
+
<compile-dependencies value="ASK" />
|
404 |
+
<always-show-controls value="false" />
|
405 |
+
</compiler>
|
406 |
+
<debugger>
|
407 |
+
<debugger-type value="JDBC" />
|
408 |
+
<use-generic-runners value="true" />
|
409 |
+
</debugger>
|
410 |
+
</operation-settings>
|
411 |
+
<ddl-file-settings>
|
412 |
+
<extensions>
|
413 |
+
<mapping file-type-id="VIEW" extensions="vw" />
|
414 |
+
<mapping file-type-id="TRIGGER" extensions="trg" />
|
415 |
+
<mapping file-type-id="PROCEDURE" extensions="prc" />
|
416 |
+
<mapping file-type-id="FUNCTION" extensions="fnc" />
|
417 |
+
<mapping file-type-id="PACKAGE" extensions="pkg" />
|
418 |
+
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
|
419 |
+
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
|
420 |
+
<mapping file-type-id="TYPE" extensions="tpe" />
|
421 |
+
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
|
422 |
+
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
|
423 |
+
</extensions>
|
424 |
+
<general>
|
425 |
+
<lookup-ddl-files value="true" />
|
426 |
+
<create-ddl-files value="false" />
|
427 |
+
<synchronize-ddl-files value="true" />
|
428 |
+
<use-qualified-names value="false" />
|
429 |
+
<make-scripts-rerunnable value="true" />
|
430 |
+
</general>
|
431 |
+
</ddl-file-settings>
|
432 |
+
<general-settings>
|
433 |
+
<regional-settings>
|
434 |
+
<date-format value="MEDIUM" />
|
435 |
+
<number-format value="UNGROUPED" />
|
436 |
+
<locale value="SYSTEM_DEFAULT" />
|
437 |
+
<use-custom-formats value="false" />
|
438 |
+
</regional-settings>
|
439 |
+
<environment>
|
440 |
+
<environment-types>
|
441 |
+
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
|
442 |
+
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
|
443 |
+
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
|
444 |
+
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
|
445 |
+
</environment-types>
|
446 |
+
<visibility-settings>
|
447 |
+
<connection-tabs value="true" />
|
448 |
+
<dialog-headers value="true" />
|
449 |
+
<object-editor-tabs value="true" />
|
450 |
+
<script-editor-tabs value="false" />
|
451 |
+
<execution-result-tabs value="true" />
|
452 |
+
</visibility-settings>
|
453 |
+
</environment>
|
454 |
+
</general-settings>
|
455 |
+
</component>
|
456 |
+
<component name="DBNavigator.Project.StatementExecutionManager">
|
457 |
+
<execution-variables />
|
458 |
+
</component>
|
459 |
+
</project>
|
.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
5 |
+
<option name="ignoredPackages">
|
6 |
+
<value>
|
7 |
+
<list size="4">
|
8 |
+
<item index="0" class="java.lang.String" itemvalue="telegram" />
|
9 |
+
<item index="1" class="java.lang.String" itemvalue="googletrans" />
|
10 |
+
<item index="2" class="java.lang.String" itemvalue="chatbotAI" />
|
11 |
+
<item index="3" class="java.lang.String" itemvalue="PIL" />
|
12 |
+
</list>
|
13 |
+
</value>
|
14 |
+
</option>
|
15 |
+
</inspection_tool>
|
16 |
+
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
17 |
+
<option name="ignoredErrors">
|
18 |
+
<list>
|
19 |
+
<option value="E741" />
|
20 |
+
<option value="W391" />
|
21 |
+
<option value="E501" />
|
22 |
+
<option value="E722" />
|
23 |
+
</list>
|
24 |
+
</option>
|
25 |
+
</inspection_tool>
|
26 |
+
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
27 |
+
<option name="ignoredErrors">
|
28 |
+
<list>
|
29 |
+
<option value="N802" />
|
30 |
+
<option value="N806" />
|
31 |
+
<option value="N801" />
|
32 |
+
<option value="N812" />
|
33 |
+
</list>
|
34 |
+
</option>
|
35 |
+
</inspection_tool>
|
36 |
+
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
37 |
+
<option name="ignoredNames">
|
38 |
+
<list>
|
39 |
+
<option value="id" />
|
40 |
+
</list>
|
41 |
+
</option>
|
42 |
+
</inspection_tool>
|
43 |
+
<inspection_tool class="PyTypeCheckerInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
44 |
+
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
45 |
+
<option name="ignoredIdentifiers">
|
46 |
+
<list>
|
47 |
+
<option value="object.__getitem__" />
|
48 |
+
<option value="smpwebapp.register.models.TestTable.objects" />
|
49 |
+
<option value="smpwebapp.register.models.User.*" />
|
50 |
+
<option value="drfproject2.app_api.models.Student.objects" />
|
51 |
+
<option value="localfood_v1.LfToken.views.signin" />
|
52 |
+
</list>
|
53 |
+
</option>
|
54 |
+
</inspection_tool>
|
55 |
+
</profile>
|
56 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (ImageColorizerDeployment)" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/ImageColorizerDeployment.iml" filepath="$PROJECT_DIR$/.idea/ImageColorizerDeployment.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/workspace.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ChangeListManager">
|
4 |
+
<list default="true" id="7fd6bdd3-2e8d-494b-9d9b-fac03d4a40f8" name="Changes" comment="" />
|
5 |
+
<option name="SHOW_DIALOG" value="false" />
|
6 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
7 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
8 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
9 |
+
</component>
|
10 |
+
<component name="FileTemplateManagerImpl">
|
11 |
+
<option name="RECENT_TEMPLATES">
|
12 |
+
<list>
|
13 |
+
<option value="Python Script" />
|
14 |
+
</list>
|
15 |
+
</option>
|
16 |
+
</component>
|
17 |
+
<component name="MarkdownSettingsMigration">
|
18 |
+
<option name="stateVersion" value="1" />
|
19 |
+
</component>
|
20 |
+
<component name="ProjectId" id="2X4Dnc6O9XTgk7IVUXBv82LOSUB" />
|
21 |
+
<component name="ProjectViewState">
|
22 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
23 |
+
<option name="showLibraryContents" value="true" />
|
24 |
+
</component>
|
25 |
+
<component name="PropertiesComponent"><![CDATA[{
|
26 |
+
"keyToString": {
|
27 |
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
28 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
29 |
+
"last_opened_file_path": "C:/Users/Admin/PycharmProjects/GSSoC23/bot-collection",
|
30 |
+
"settings.editor.selected.configurable": "vcs.Subversion"
|
31 |
+
}
|
32 |
+
}]]></component>
|
33 |
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
34 |
+
<component name="SvnConfiguration">
|
35 |
+
<configuration>C:\Users\Admin\AppData\Roaming\Subversion</configuration>
|
36 |
+
</component>
|
37 |
+
<component name="TaskManager">
|
38 |
+
<task active="true" id="Default" summary="Default task">
|
39 |
+
<changelist id="7fd6bdd3-2e8d-494b-9d9b-fac03d4a40f8" name="Changes" comment="" />
|
40 |
+
<created>1697879626738</created>
|
41 |
+
<option name="number" value="Default" />
|
42 |
+
<option name="presentableId" value="Default" />
|
43 |
+
<updated>1697879626738</updated>
|
44 |
+
</task>
|
45 |
+
<servers />
|
46 |
+
</component>
|
47 |
+
</project>
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
title: ImageColorizerDeployment
|
3 |
-
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.50.2
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: ImageColorizerDeployment
|
3 |
+
app_file: app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 3.50.2
|
|
|
|
|
6 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
model = tf.keras.models.load_model("landColorGenV1.keras")
|
6 |
+
|
7 |
+
def generate_image(input_img):
|
8 |
+
input_img = tf.convert_to_tensor(input_img)
|
9 |
+
input_img = tf.cast(input_img,tf.float32)
|
10 |
+
init_shape = input_img.shape
|
11 |
+
input_img = tf.image.resize(input_img, [256, 256],
|
12 |
+
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
|
13 |
+
input_img = (input_img / 127.5) -1
|
14 |
+
input_img = tf.reshape(input_img,(1,256,256,3))
|
15 |
+
output = model(input_img,training=True)
|
16 |
+
# out_img = output[0].numpy()* 0.5 + 0.5
|
17 |
+
out_img = tf.image.resize(output[0], [init_shape[0],init_shape[1]],
|
18 |
+
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
|
19 |
+
out_img = out_img.numpy()*0.5 + 0.5
|
20 |
+
return out_img
|
21 |
+
app = gr.Interface(fn = generate_image, inputs="image", outputs="image")
|
22 |
+
app.launch()
|
landColorGenV1.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2ec205963d1ae2c7cc7c8a763bf0bdd5c09dde9ab839203cd410442f79bfd4a5
|
3 |
+
size 217824400
|
venv/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# created by virtualenv automatically
|
2 |
+
*
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/INSTALLER
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pip
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2007 Pallets
|
2 |
+
|
3 |
+
Redistribution and use in source and binary forms, with or without
|
4 |
+
modification, are permitted provided that the following conditions are
|
5 |
+
met:
|
6 |
+
|
7 |
+
1. Redistributions of source code must retain the above copyright
|
8 |
+
notice, this list of conditions and the following disclaimer.
|
9 |
+
|
10 |
+
2. Redistributions in binary form must reproduce the above copyright
|
11 |
+
notice, this list of conditions and the following disclaimer in the
|
12 |
+
documentation and/or other materials provided with the distribution.
|
13 |
+
|
14 |
+
3. Neither the name of the copyright holder nor the names of its
|
15 |
+
contributors may be used to endorse or promote products derived from
|
16 |
+
this software without specific prior written permission.
|
17 |
+
|
18 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
21 |
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22 |
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
24 |
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25 |
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26 |
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27 |
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28 |
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/METADATA
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Metadata-Version: 2.1
|
2 |
+
Name: Jinja2
|
3 |
+
Version: 3.1.2
|
4 |
+
Summary: A very fast and expressive template engine.
|
5 |
+
Home-page: https://palletsprojects.com/p/jinja/
|
6 |
+
Author: Armin Ronacher
|
7 |
+
Author-email: [email protected]
|
8 |
+
Maintainer: Pallets
|
9 |
+
Maintainer-email: [email protected]
|
10 |
+
License: BSD-3-Clause
|
11 |
+
Project-URL: Donate, https://palletsprojects.com/donate
|
12 |
+
Project-URL: Documentation, https://jinja.palletsprojects.com/
|
13 |
+
Project-URL: Changes, https://jinja.palletsprojects.com/changes/
|
14 |
+
Project-URL: Source Code, https://github.com/pallets/jinja/
|
15 |
+
Project-URL: Issue Tracker, https://github.com/pallets/jinja/issues/
|
16 |
+
Project-URL: Twitter, https://twitter.com/PalletsTeam
|
17 |
+
Project-URL: Chat, https://discord.gg/pallets
|
18 |
+
Platform: UNKNOWN
|
19 |
+
Classifier: Development Status :: 5 - Production/Stable
|
20 |
+
Classifier: Environment :: Web Environment
|
21 |
+
Classifier: Intended Audience :: Developers
|
22 |
+
Classifier: License :: OSI Approved :: BSD License
|
23 |
+
Classifier: Operating System :: OS Independent
|
24 |
+
Classifier: Programming Language :: Python
|
25 |
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
26 |
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
27 |
+
Requires-Python: >=3.7
|
28 |
+
Description-Content-Type: text/x-rst
|
29 |
+
License-File: LICENSE.rst
|
30 |
+
Requires-Dist: MarkupSafe (>=2.0)
|
31 |
+
Provides-Extra: i18n
|
32 |
+
Requires-Dist: Babel (>=2.7) ; extra == 'i18n'
|
33 |
+
|
34 |
+
Jinja
|
35 |
+
=====
|
36 |
+
|
37 |
+
Jinja is a fast, expressive, extensible templating engine. Special
|
38 |
+
placeholders in the template allow writing code similar to Python
|
39 |
+
syntax. Then the template is passed data to render the final document.
|
40 |
+
|
41 |
+
It includes:
|
42 |
+
|
43 |
+
- Template inheritance and inclusion.
|
44 |
+
- Define and import macros within templates.
|
45 |
+
- HTML templates can use autoescaping to prevent XSS from untrusted
|
46 |
+
user input.
|
47 |
+
- A sandboxed environment can safely render untrusted templates.
|
48 |
+
- AsyncIO support for generating templates and calling async
|
49 |
+
functions.
|
50 |
+
- I18N support with Babel.
|
51 |
+
- Templates are compiled to optimized Python code just-in-time and
|
52 |
+
cached, or can be compiled ahead-of-time.
|
53 |
+
- Exceptions point to the correct line in templates to make debugging
|
54 |
+
easier.
|
55 |
+
- Extensible filters, tests, functions, and even syntax.
|
56 |
+
|
57 |
+
Jinja's philosophy is that while application logic belongs in Python if
|
58 |
+
possible, it shouldn't make the template designer's job difficult by
|
59 |
+
restricting functionality too much.
|
60 |
+
|
61 |
+
|
62 |
+
Installing
|
63 |
+
----------
|
64 |
+
|
65 |
+
Install and update using `pip`_:
|
66 |
+
|
67 |
+
.. code-block:: text
|
68 |
+
|
69 |
+
$ pip install -U Jinja2
|
70 |
+
|
71 |
+
.. _pip: https://pip.pypa.io/en/stable/getting-started/
|
72 |
+
|
73 |
+
|
74 |
+
In A Nutshell
|
75 |
+
-------------
|
76 |
+
|
77 |
+
.. code-block:: jinja
|
78 |
+
|
79 |
+
{% extends "base.html" %}
|
80 |
+
{% block title %}Members{% endblock %}
|
81 |
+
{% block content %}
|
82 |
+
<ul>
|
83 |
+
{% for user in users %}
|
84 |
+
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
|
85 |
+
{% endfor %}
|
86 |
+
</ul>
|
87 |
+
{% endblock %}
|
88 |
+
|
89 |
+
|
90 |
+
Donate
|
91 |
+
------
|
92 |
+
|
93 |
+
The Pallets organization develops and supports Jinja and other popular
|
94 |
+
packages. In order to grow the community of contributors and users, and
|
95 |
+
allow the maintainers to devote more time to the projects, `please
|
96 |
+
donate today`_.
|
97 |
+
|
98 |
+
.. _please donate today: https://palletsprojects.com/donate
|
99 |
+
|
100 |
+
|
101 |
+
Links
|
102 |
+
-----
|
103 |
+
|
104 |
+
- Documentation: https://jinja.palletsprojects.com/
|
105 |
+
- Changes: https://jinja.palletsprojects.com/changes/
|
106 |
+
- PyPI Releases: https://pypi.org/project/Jinja2/
|
107 |
+
- Source Code: https://github.com/pallets/jinja/
|
108 |
+
- Issue Tracker: https://github.com/pallets/jinja/issues/
|
109 |
+
- Website: https://palletsprojects.com/p/jinja/
|
110 |
+
- Twitter: https://twitter.com/PalletsTeam
|
111 |
+
- Chat: https://discord.gg/pallets
|
112 |
+
|
113 |
+
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/RECORD
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Jinja2-3.1.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
2 |
+
Jinja2-3.1.2.dist-info/LICENSE.rst,sha256=O0nc7kEF6ze6wQ-vG-JgQI_oXSUrjp3y4JefweCUQ3s,1475
|
3 |
+
Jinja2-3.1.2.dist-info/METADATA,sha256=PZ6v2SIidMNixR7MRUX9f7ZWsPwtXanknqiZUmRbh4U,3539
|
4 |
+
Jinja2-3.1.2.dist-info/RECORD,,
|
5 |
+
Jinja2-3.1.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
6 |
+
Jinja2-3.1.2.dist-info/entry_points.txt,sha256=zRd62fbqIyfUpsRtU7EVIFyiu1tPwfgO7EvPErnxgTE,59
|
7 |
+
Jinja2-3.1.2.dist-info/top_level.txt,sha256=PkeVWtLb3-CqjWi1fO29OCbj55EhX_chhKrCdrVe_zs,7
|
8 |
+
jinja2/__init__.py,sha256=8vGduD8ytwgD6GDSqpYc2m3aU-T7PKOAddvVXgGr_Fs,1927
|
9 |
+
jinja2/__pycache__/__init__.cpython-38.pyc,,
|
10 |
+
jinja2/__pycache__/_identifier.cpython-38.pyc,,
|
11 |
+
jinja2/__pycache__/async_utils.cpython-38.pyc,,
|
12 |
+
jinja2/__pycache__/bccache.cpython-38.pyc,,
|
13 |
+
jinja2/__pycache__/compiler.cpython-38.pyc,,
|
14 |
+
jinja2/__pycache__/constants.cpython-38.pyc,,
|
15 |
+
jinja2/__pycache__/debug.cpython-38.pyc,,
|
16 |
+
jinja2/__pycache__/defaults.cpython-38.pyc,,
|
17 |
+
jinja2/__pycache__/environment.cpython-38.pyc,,
|
18 |
+
jinja2/__pycache__/exceptions.cpython-38.pyc,,
|
19 |
+
jinja2/__pycache__/ext.cpython-38.pyc,,
|
20 |
+
jinja2/__pycache__/filters.cpython-38.pyc,,
|
21 |
+
jinja2/__pycache__/idtracking.cpython-38.pyc,,
|
22 |
+
jinja2/__pycache__/lexer.cpython-38.pyc,,
|
23 |
+
jinja2/__pycache__/loaders.cpython-38.pyc,,
|
24 |
+
jinja2/__pycache__/meta.cpython-38.pyc,,
|
25 |
+
jinja2/__pycache__/nativetypes.cpython-38.pyc,,
|
26 |
+
jinja2/__pycache__/nodes.cpython-38.pyc,,
|
27 |
+
jinja2/__pycache__/optimizer.cpython-38.pyc,,
|
28 |
+
jinja2/__pycache__/parser.cpython-38.pyc,,
|
29 |
+
jinja2/__pycache__/runtime.cpython-38.pyc,,
|
30 |
+
jinja2/__pycache__/sandbox.cpython-38.pyc,,
|
31 |
+
jinja2/__pycache__/tests.cpython-38.pyc,,
|
32 |
+
jinja2/__pycache__/utils.cpython-38.pyc,,
|
33 |
+
jinja2/__pycache__/visitor.cpython-38.pyc,,
|
34 |
+
jinja2/_identifier.py,sha256=_zYctNKzRqlk_murTNlzrju1FFJL7Va_Ijqqd7ii2lU,1958
|
35 |
+
jinja2/async_utils.py,sha256=dHlbTeaxFPtAOQEYOGYh_PHcDT0rsDaUJAFDl_0XtTg,2472
|
36 |
+
jinja2/bccache.py,sha256=mhz5xtLxCcHRAa56azOhphIAe19u1we0ojifNMClDio,14061
|
37 |
+
jinja2/compiler.py,sha256=Gs-N8ThJ7OWK4-reKoO8Wh1ZXz95MVphBKNVf75qBr8,72172
|
38 |
+
jinja2/constants.py,sha256=GMoFydBF_kdpaRKPoM5cl5MviquVRLVyZtfp5-16jg0,1433
|
39 |
+
jinja2/debug.py,sha256=iWJ432RadxJNnaMOPrjIDInz50UEgni3_HKuFXi2vuQ,6299
|
40 |
+
jinja2/defaults.py,sha256=boBcSw78h-lp20YbaXSJsqkAI2uN_mD_TtCydpeq5wU,1267
|
41 |
+
jinja2/environment.py,sha256=6uHIcc7ZblqOMdx_uYNKqRnnwAF0_nzbyeMP9FFtuh4,61349
|
42 |
+
jinja2/exceptions.py,sha256=ioHeHrWwCWNaXX1inHmHVblvc4haO7AXsjCp3GfWvx0,5071
|
43 |
+
jinja2/ext.py,sha256=ivr3P7LKbddiXDVez20EflcO3q2aHQwz9P_PgWGHVqE,31502
|
44 |
+
jinja2/filters.py,sha256=9js1V-h2RlyW90IhLiBGLM2U-k6SCy2F4BUUMgB3K9Q,53509
|
45 |
+
jinja2/idtracking.py,sha256=GfNmadir4oDALVxzn3DL9YInhJDr69ebXeA2ygfuCGA,10704
|
46 |
+
jinja2/lexer.py,sha256=DW2nX9zk-6MWp65YR2bqqj0xqCvLtD-u9NWT8AnFRxQ,29726
|
47 |
+
jinja2/loaders.py,sha256=BfptfvTVpClUd-leMkHczdyPNYFzp_n7PKOJ98iyHOg,23207
|
48 |
+
jinja2/meta.py,sha256=GNPEvifmSaU3CMxlbheBOZjeZ277HThOPUTf1RkppKQ,4396
|
49 |
+
jinja2/nativetypes.py,sha256=DXgORDPRmVWgy034H0xL8eF7qYoK3DrMxs-935d0Fzk,4226
|
50 |
+
jinja2/nodes.py,sha256=i34GPRAZexXMT6bwuf5SEyvdmS-bRCy9KMjwN5O6pjk,34550
|
51 |
+
jinja2/optimizer.py,sha256=tHkMwXxfZkbfA1KmLcqmBMSaz7RLIvvItrJcPoXTyD8,1650
|
52 |
+
jinja2/parser.py,sha256=nHd-DFHbiygvfaPtm9rcQXJChZG7DPsWfiEsqfwKerY,39595
|
53 |
+
jinja2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54 |
+
jinja2/runtime.py,sha256=5CmD5BjbEJxSiDNTFBeKCaq8qU4aYD2v6q2EluyExms,33476
|
55 |
+
jinja2/sandbox.py,sha256=Y0xZeXQnH6EX5VjaV2YixESxoepnRbW_3UeQosaBU3M,14584
|
56 |
+
jinja2/tests.py,sha256=Am5Z6Lmfr2XaH_npIfJJ8MdXtWsbLjMULZJulTAj30E,5905
|
57 |
+
jinja2/utils.py,sha256=u9jXESxGn8ATZNVolwmkjUVu4SA-tLgV0W7PcSfPfdQ,23965
|
58 |
+
jinja2/visitor.py,sha256=MH14C6yq24G_KVtWzjwaI7Wg14PCJIYlWW1kpkxYak0,3568
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/WHEEL
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Wheel-Version: 1.0
|
2 |
+
Generator: bdist_wheel (0.37.1)
|
3 |
+
Root-Is-Purelib: true
|
4 |
+
Tag: py3-none-any
|
5 |
+
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/entry_points.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[babel.extractors]
|
2 |
+
jinja2 = jinja2.ext:babel_extract[i18n]
|
venv/Lib/site-packages/Jinja2-3.1.2.dist-info/top_level.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
jinja2
|
venv/Lib/site-packages/Markdown-3.5.dist-info/INSTALLER
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pip
|
venv/Lib/site-packages/Markdown-3.5.dist-info/LICENSE.md
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
|
2 |
+
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
|
3 |
+
Copyright 2004 Manfred Stienstra (the original version)
|
4 |
+
|
5 |
+
All rights reserved.
|
6 |
+
|
7 |
+
Redistribution and use in source and binary forms, with or without
|
8 |
+
modification, are permitted provided that the following conditions are met:
|
9 |
+
|
10 |
+
* Redistributions of source code must retain the above copyright
|
11 |
+
notice, this list of conditions and the following disclaimer.
|
12 |
+
* Redistributions in binary form must reproduce the above copyright
|
13 |
+
notice, this list of conditions and the following disclaimer in the
|
14 |
+
documentation and/or other materials provided with the distribution.
|
15 |
+
* Neither the name of the Python Markdown Project nor the
|
16 |
+
names of its contributors may be used to endorse or promote products
|
17 |
+
derived from this software without specific prior written permission.
|
18 |
+
|
19 |
+
THIS SOFTWARE IS PROVIDED BY THE PYTHON MARKDOWN PROJECT ''AS IS'' AND ANY
|
20 |
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21 |
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22 |
+
DISCLAIMED. IN NO EVENT SHALL ANY CONTRIBUTORS TO THE PYTHON MARKDOWN PROJECT
|
23 |
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
+
POSSIBILITY OF SUCH DAMAGE.
|
venv/Lib/site-packages/Markdown-3.5.dist-info/METADATA
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Metadata-Version: 2.1
|
2 |
+
Name: Markdown
|
3 |
+
Version: 3.5
|
4 |
+
Summary: Python implementation of John Gruber's Markdown.
|
5 |
+
Author: Manfred Stienstra, Yuri Takhteyev
|
6 |
+
Author-email: Waylan limberg <[email protected]>
|
7 |
+
Maintainer: Isaac Muse
|
8 |
+
Maintainer-email: Waylan Limberg <[email protected]>
|
9 |
+
License: Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
|
10 |
+
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
|
11 |
+
Copyright 2004 Manfred Stienstra (the original version)
|
12 |
+
|
13 |
+
All rights reserved.
|
14 |
+
|
15 |
+
Redistribution and use in source and binary forms, with or without
|
16 |
+
modification, are permitted provided that the following conditions are met:
|
17 |
+
|
18 |
+
* Redistributions of source code must retain the above copyright
|
19 |
+
notice, this list of conditions and the following disclaimer.
|
20 |
+
* Redistributions in binary form must reproduce the above copyright
|
21 |
+
notice, this list of conditions and the following disclaimer in the
|
22 |
+
documentation and/or other materials provided with the distribution.
|
23 |
+
* Neither the name of the Python Markdown Project nor the
|
24 |
+
names of its contributors may be used to endorse or promote products
|
25 |
+
derived from this software without specific prior written permission.
|
26 |
+
|
27 |
+
THIS SOFTWARE IS PROVIDED BY THE PYTHON MARKDOWN PROJECT ''AS IS'' AND ANY
|
28 |
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
29 |
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30 |
+
DISCLAIMED. IN NO EVENT SHALL ANY CONTRIBUTORS TO THE PYTHON MARKDOWN PROJECT
|
31 |
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
32 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
33 |
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
34 |
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
35 |
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
36 |
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
37 |
+
POSSIBILITY OF SUCH DAMAGE.
|
38 |
+
|
39 |
+
Project-URL: Homepage, https://Python-Markdown.github.io/
|
40 |
+
Project-URL: Documentation, https://Python-Markdown.github.io/
|
41 |
+
Project-URL: Repository, https://github.com/Python-Markdown/markdown
|
42 |
+
Project-URL: Issue Tracker, https://github.com/Python-Markdown/markdown/issues
|
43 |
+
Project-URL: Changelog, https://github.com/Python-Markdown/markdown/blob/master/docs/change_log/index.md
|
44 |
+
Keywords: markdown,markdown-parser,python-markdown,markdown-to-html
|
45 |
+
Classifier: Development Status :: 5 - Production/Stable
|
46 |
+
Classifier: License :: OSI Approved :: BSD License
|
47 |
+
Classifier: Operating System :: OS Independent
|
48 |
+
Classifier: Programming Language :: Python
|
49 |
+
Classifier: Programming Language :: Python :: 3
|
50 |
+
Classifier: Programming Language :: Python :: 3.8
|
51 |
+
Classifier: Programming Language :: Python :: 3.9
|
52 |
+
Classifier: Programming Language :: Python :: 3.10
|
53 |
+
Classifier: Programming Language :: Python :: 3.11
|
54 |
+
Classifier: Programming Language :: Python :: 3.12
|
55 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
56 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
57 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
58 |
+
Classifier: Topic :: Communications :: Email :: Filters
|
59 |
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
|
60 |
+
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
|
61 |
+
Classifier: Topic :: Software Development :: Documentation
|
62 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
63 |
+
Classifier: Topic :: Text Processing :: Filters
|
64 |
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
65 |
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
66 |
+
Requires-Python: >=3.8
|
67 |
+
Description-Content-Type: text/markdown
|
68 |
+
License-File: LICENSE.md
|
69 |
+
Requires-Dist: importlib-metadata >=4.4 ; python_version < "3.10"
|
70 |
+
Provides-Extra: docs
|
71 |
+
Requires-Dist: mkdocs >=1.5 ; extra == 'docs'
|
72 |
+
Requires-Dist: mkdocs-nature >=0.6 ; extra == 'docs'
|
73 |
+
Requires-Dist: mdx-gh-links >=0.2 ; extra == 'docs'
|
74 |
+
Requires-Dist: mkdocstrings[python] ; extra == 'docs'
|
75 |
+
Requires-Dist: mkdocs-gen-files ; extra == 'docs'
|
76 |
+
Requires-Dist: mkdocs-section-index ; extra == 'docs'
|
77 |
+
Requires-Dist: mkdocs-literate-nav ; extra == 'docs'
|
78 |
+
Provides-Extra: testing
|
79 |
+
Requires-Dist: coverage ; extra == 'testing'
|
80 |
+
Requires-Dist: pyyaml ; extra == 'testing'
|
81 |
+
|
82 |
+
[Python-Markdown][]
|
83 |
+
===================
|
84 |
+
|
85 |
+
[![Build Status][build-button]][build]
|
86 |
+
[![Coverage Status][codecov-button]][codecov]
|
87 |
+
[![Latest Version][mdversion-button]][md-pypi]
|
88 |
+
[![Python Versions][pyversion-button]][md-pypi]
|
89 |
+
[![BSD License][bsdlicense-button]][bsdlicense]
|
90 |
+
[![Code of Conduct][codeofconduct-button]][Code of Conduct]
|
91 |
+
|
92 |
+
[build-button]: https://github.com/Python-Markdown/markdown/workflows/CI/badge.svg?event=push
|
93 |
+
[build]: https://github.com/Python-Markdown/markdown/actions?query=workflow%3ACI+event%3Apush
|
94 |
+
[codecov-button]: https://codecov.io/gh/Python-Markdown/markdown/branch/master/graph/badge.svg
|
95 |
+
[codecov]: https://codecov.io/gh/Python-Markdown/markdown
|
96 |
+
[mdversion-button]: https://img.shields.io/pypi/v/Markdown.svg
|
97 |
+
[md-pypi]: https://pypi.org/project/Markdown/
|
98 |
+
[pyversion-button]: https://img.shields.io/pypi/pyversions/Markdown.svg
|
99 |
+
[bsdlicense-button]: https://img.shields.io/badge/license-BSD-yellow.svg
|
100 |
+
[bsdlicense]: https://opensource.org/licenses/BSD-3-Clause
|
101 |
+
[codeofconduct-button]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square
|
102 |
+
[Code of Conduct]: https://github.com/Python-Markdown/markdown/blob/master/CODE_OF_CONDUCT.md
|
103 |
+
|
104 |
+
This is a Python implementation of John Gruber's [Markdown][].
|
105 |
+
It is almost completely compliant with the reference implementation,
|
106 |
+
though there are a few known issues. See [Features][] for information
|
107 |
+
on what exactly is supported and what is not. Additional features are
|
108 |
+
supported by the [Available Extensions][].
|
109 |
+
|
110 |
+
[Python-Markdown]: https://Python-Markdown.github.io/
|
111 |
+
[Markdown]: https://daringfireball.net/projects/markdown/
|
112 |
+
[Features]: https://Python-Markdown.github.io#Features
|
113 |
+
[Available Extensions]: https://Python-Markdown.github.io/extensions
|
114 |
+
|
115 |
+
Documentation
|
116 |
+
-------------
|
117 |
+
|
118 |
+
```bash
|
119 |
+
pip install markdown
|
120 |
+
```
|
121 |
+
```python
|
122 |
+
import markdown
|
123 |
+
html = markdown.markdown(your_text_string)
|
124 |
+
```
|
125 |
+
|
126 |
+
For more advanced [installation] and [usage] documentation, see the `docs/` directory
|
127 |
+
of the distribution or the project website at <https://Python-Markdown.github.io/>.
|
128 |
+
|
129 |
+
[installation]: https://python-markdown.github.io/install/
|
130 |
+
[usage]: https://python-markdown.github.io/reference/
|
131 |
+
|
132 |
+
See the change log at <https://Python-Markdown.github.io/change_log>.
|
133 |
+
|
134 |
+
Support
|
135 |
+
-------
|
136 |
+
|
137 |
+
You may report bugs, ask for help, and discuss various other issues on the [bug tracker][].
|
138 |
+
|
139 |
+
[bug tracker]: https://github.com/Python-Markdown/markdown/issues
|
140 |
+
|
141 |
+
Code of Conduct
|
142 |
+
---------------
|
143 |
+
|
144 |
+
Everyone interacting in the Python-Markdown project's code bases, issue trackers,
|
145 |
+
and mailing lists is expected to follow the [Code of Conduct].
|
venv/Lib/site-packages/Markdown-3.5.dist-info/RECORD
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
../../Scripts/markdown_py.exe,sha256=W0nOyZCjTfRSA9FbsDts11uHevrf7onejdVTL4Ym6KM,106402
|
2 |
+
Markdown-3.5.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
3 |
+
Markdown-3.5.dist-info/LICENSE.md,sha256=bxGTy2NHGOZcOlN9biXr1hSCDsDvaTz8EiSBEmONZNo,1645
|
4 |
+
Markdown-3.5.dist-info/METADATA,sha256=iQt0HX4MdKZFK8922mRNjPBNjkP_scG3BekmNX2p9Ms,7063
|
5 |
+
Markdown-3.5.dist-info/RECORD,,
|
6 |
+
Markdown-3.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
7 |
+
Markdown-3.5.dist-info/entry_points.txt,sha256=lMEyiiA_ZZyfPCBlDviBl-SiU0cfoeuEKpwxw361sKQ,1102
|
8 |
+
Markdown-3.5.dist-info/top_level.txt,sha256=IAxs8x618RXoH1uCqeLLxXsDefJvE_mIibr_M4sOlyk,9
|
9 |
+
markdown/__init__.py,sha256=dfzwwdpG9L8QLEPBpLFPIHx_BN056aZXp9xZifTxYIU,1777
|
10 |
+
markdown/__main__.py,sha256=innFBxRqwPBNxG1zhKktJji4bnRKtVyYYd30ID13Tcw,5859
|
11 |
+
markdown/__meta__.py,sha256=u8BqcMQ7h7_NM3W2d69x7FVcWWmlGjNVcylnbYkgD0g,1712
|
12 |
+
markdown/__pycache__/__init__.cpython-38.pyc,,
|
13 |
+
markdown/__pycache__/__main__.cpython-38.pyc,,
|
14 |
+
markdown/__pycache__/__meta__.cpython-38.pyc,,
|
15 |
+
markdown/__pycache__/blockparser.cpython-38.pyc,,
|
16 |
+
markdown/__pycache__/blockprocessors.cpython-38.pyc,,
|
17 |
+
markdown/__pycache__/core.cpython-38.pyc,,
|
18 |
+
markdown/__pycache__/htmlparser.cpython-38.pyc,,
|
19 |
+
markdown/__pycache__/inlinepatterns.cpython-38.pyc,,
|
20 |
+
markdown/__pycache__/postprocessors.cpython-38.pyc,,
|
21 |
+
markdown/__pycache__/preprocessors.cpython-38.pyc,,
|
22 |
+
markdown/__pycache__/serializers.cpython-38.pyc,,
|
23 |
+
markdown/__pycache__/test_tools.cpython-38.pyc,,
|
24 |
+
markdown/__pycache__/treeprocessors.cpython-38.pyc,,
|
25 |
+
markdown/__pycache__/util.cpython-38.pyc,,
|
26 |
+
markdown/blockparser.py,sha256=aUO3fGoU40umw1SA_dqIZ3HqcDCqBDVgk3NPVfXzePU,5629
|
27 |
+
markdown/blockprocessors.py,sha256=AAzGuQCeiG2LXotk302P_oCdkC93nWe3Mh7MKg4W95Y,25981
|
28 |
+
markdown/core.py,sha256=leTlfDAqF2o5iagiN4SexulsVeF-aG3Xe-LOPQUtxJo,21594
|
29 |
+
markdown/extensions/__init__.py,sha256=hRDHTu2R_mp6V-qqXDLrCxvdmEmgfVY0LCUMifl5uG4,4779
|
30 |
+
markdown/extensions/__pycache__/__init__.cpython-38.pyc,,
|
31 |
+
markdown/extensions/__pycache__/abbr.cpython-38.pyc,,
|
32 |
+
markdown/extensions/__pycache__/admonition.cpython-38.pyc,,
|
33 |
+
markdown/extensions/__pycache__/attr_list.cpython-38.pyc,,
|
34 |
+
markdown/extensions/__pycache__/codehilite.cpython-38.pyc,,
|
35 |
+
markdown/extensions/__pycache__/def_list.cpython-38.pyc,,
|
36 |
+
markdown/extensions/__pycache__/extra.cpython-38.pyc,,
|
37 |
+
markdown/extensions/__pycache__/fenced_code.cpython-38.pyc,,
|
38 |
+
markdown/extensions/__pycache__/footnotes.cpython-38.pyc,,
|
39 |
+
markdown/extensions/__pycache__/legacy_attrs.cpython-38.pyc,,
|
40 |
+
markdown/extensions/__pycache__/legacy_em.cpython-38.pyc,,
|
41 |
+
markdown/extensions/__pycache__/md_in_html.cpython-38.pyc,,
|
42 |
+
markdown/extensions/__pycache__/meta.cpython-38.pyc,,
|
43 |
+
markdown/extensions/__pycache__/nl2br.cpython-38.pyc,,
|
44 |
+
markdown/extensions/__pycache__/sane_lists.cpython-38.pyc,,
|
45 |
+
markdown/extensions/__pycache__/smarty.cpython-38.pyc,,
|
46 |
+
markdown/extensions/__pycache__/tables.cpython-38.pyc,,
|
47 |
+
markdown/extensions/__pycache__/toc.cpython-38.pyc,,
|
48 |
+
markdown/extensions/__pycache__/wikilinks.cpython-38.pyc,,
|
49 |
+
markdown/extensions/abbr.py,sha256=okqFfKZlCJf5vpQuFge5PCW5fCp5E2JDFN2m_jxOePk,3402
|
50 |
+
markdown/extensions/admonition.py,sha256=4OVSPQ7Zk4Ao_eMItpetFHHc-xJ5TH4KLfDLWf_dpFM,6230
|
51 |
+
markdown/extensions/attr_list.py,sha256=T4oJp198fNEKK3O60qlsfimlArSnJ_6TxeB225IZu8c,6579
|
52 |
+
markdown/extensions/codehilite.py,sha256=fVq1n9p-iuZC3Mk6Khh0DiaQsjUUAaesQ9fEf__6K9I,13160
|
53 |
+
markdown/extensions/def_list.py,sha256=xyXwIo7pCBmRx0RQ852wJt5e5t4HhfSM3cxvbm5QlAc,3932
|
54 |
+
markdown/extensions/extra.py,sha256=1vleT284kued4HQBtF83IjSumJVo0q3ng6MjTkVNfNQ,2163
|
55 |
+
markdown/extensions/fenced_code.py,sha256=YIQcUDB3uIiENKYp6iaJa95QoqwWpr8aFCYZ5tG2PQ8,7550
|
56 |
+
markdown/extensions/footnotes.py,sha256=WiQ3Cri68C2i0rROD4yRaL-N8nflJ3G7hWu7BPFWjVE,16065
|
57 |
+
markdown/extensions/legacy_attrs.py,sha256=P3QiN45zxbgY72J7e1_KXKqTf9u67ChJ8StihVeknIw,2609
|
58 |
+
markdown/extensions/legacy_em.py,sha256=-Z_w4PEGSS-Xg-2-BtGAnXwwy5g5GDgv2tngASnPgxg,1693
|
59 |
+
markdown/extensions/md_in_html.py,sha256=gIFrUj7FliN8Ujn-rGjq066E_rI8PhjS5u5XNFWmyFw,16160
|
60 |
+
markdown/extensions/meta.py,sha256=sERcUS76E-BrIr-fCQ3CvLdqTH5O_gQSvIIDhMkTglk,2529
|
61 |
+
markdown/extensions/nl2br.py,sha256=9KKcrPs62c3ENNnmOJZs0rrXXqUtTCfd43j1_OPpmgU,1090
|
62 |
+
markdown/extensions/sane_lists.py,sha256=Pg5jMN2bXTfUumPRmeQbDquro7_OudzS193Qo1Hohnc,1997
|
63 |
+
markdown/extensions/smarty.py,sha256=CYUKV8D635mwDetsNdxcyQp9lmIVXN-f09OMz81kXUA,10491
|
64 |
+
markdown/extensions/tables.py,sha256=UK_B3gnOW3c1HMfmnBoqPsWH8nS68M7Eb9tbxtoGnHk,8343
|
65 |
+
markdown/extensions/toc.py,sha256=vFG2Mv4fwGcmenskRKUq2EU1VmukpLOnPAmsOnUBIng,14655
|
66 |
+
markdown/extensions/wikilinks.py,sha256=bz0ErE3TUfoO7k8ZKaz3plzWE0gY05IcnW6ZKV0YXHQ,3135
|
67 |
+
markdown/htmlparser.py,sha256=oPc6fehQpfhpZ65KQX5r0o28jvT4ECzHthiPu9dKKfY,13623
|
68 |
+
markdown/inlinepatterns.py,sha256=t2gBFyR_-xyfpAGCQiaw9tDASmM9moLXn759R8Ub0MY,37640
|
69 |
+
markdown/postprocessors.py,sha256=k2i-A6_Qw1wF6cs7-U9v6rARGsTo9fa6jaBJ3nAQxEA,4717
|
70 |
+
markdown/preprocessors.py,sha256=Vx5qfjRFX-tVRxPZd1hHsiHuS4bARROHlcrLia1oLks,3210
|
71 |
+
markdown/serializers.py,sha256=A6YLaHEl8tLltrogg87S5g2ZTJDdsMEi1akpDv9xpEE,6958
|
72 |
+
markdown/test_tools.py,sha256=MtN4cf3ZPDtb83wXLTol-3q3aIGRIkJ2zWr6fd-RgVE,8662
|
73 |
+
markdown/treeprocessors.py,sha256=CsgueK9auuxEFUFu1uML0m3AnjJ0vxtIsANlzbTKuZA,17250
|
74 |
+
markdown/util.py,sha256=juCzGRQSAlNlOq7MpcfONsE4eYBthTZWX0CZ-Xfwlas,13136
|
venv/Lib/site-packages/Markdown-3.5.dist-info/WHEEL
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Wheel-Version: 1.0
|
2 |
+
Generator: bdist_wheel (0.41.2)
|
3 |
+
Root-Is-Purelib: true
|
4 |
+
Tag: py3-none-any
|
5 |
+
|
venv/Lib/site-packages/Markdown-3.5.dist-info/entry_points.txt
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[console_scripts]
|
2 |
+
markdown_py = markdown.__main__:run
|
3 |
+
|
4 |
+
[markdown.extensions]
|
5 |
+
abbr = markdown.extensions.abbr:AbbrExtension
|
6 |
+
admonition = markdown.extensions.admonition:AdmonitionExtension
|
7 |
+
attr_list = markdown.extensions.attr_list:AttrListExtension
|
8 |
+
codehilite = markdown.extensions.codehilite:CodeHiliteExtension
|
9 |
+
def_list = markdown.extensions.def_list:DefListExtension
|
10 |
+
extra = markdown.extensions.extra:ExtraExtension
|
11 |
+
fenced_code = markdown.extensions.fenced_code:FencedCodeExtension
|
12 |
+
footnotes = markdown.extensions.footnotes:FootnoteExtension
|
13 |
+
legacy_attrs = markdown.extensions.legacy_attrs:LegacyAttrExtension
|
14 |
+
legacy_em = markdown.extensions.legacy_em:LegacyEmExtension
|
15 |
+
md_in_html = markdown.extensions.md_in_html:MarkdownInHtmlExtension
|
16 |
+
meta = markdown.extensions.meta:MetaExtension
|
17 |
+
nl2br = markdown.extensions.nl2br:Nl2BrExtension
|
18 |
+
sane_lists = markdown.extensions.sane_lists:SaneListExtension
|
19 |
+
smarty = markdown.extensions.smarty:SmartyExtension
|
20 |
+
tables = markdown.extensions.tables:TableExtension
|
21 |
+
toc = markdown.extensions.toc:TocExtension
|
22 |
+
wikilinks = markdown.extensions.wikilinks:WikiLinkExtension
|
venv/Lib/site-packages/Markdown-3.5.dist-info/top_level.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
markdown
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/INSTALLER
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pip
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/LICENSE.rst
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2010 Pallets
|
2 |
+
|
3 |
+
Redistribution and use in source and binary forms, with or without
|
4 |
+
modification, are permitted provided that the following conditions are
|
5 |
+
met:
|
6 |
+
|
7 |
+
1. Redistributions of source code must retain the above copyright
|
8 |
+
notice, this list of conditions and the following disclaimer.
|
9 |
+
|
10 |
+
2. Redistributions in binary form must reproduce the above copyright
|
11 |
+
notice, this list of conditions and the following disclaimer in the
|
12 |
+
documentation and/or other materials provided with the distribution.
|
13 |
+
|
14 |
+
3. Neither the name of the copyright holder nor the names of its
|
15 |
+
contributors may be used to endorse or promote products derived from
|
16 |
+
this software without specific prior written permission.
|
17 |
+
|
18 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
21 |
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22 |
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
24 |
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25 |
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26 |
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27 |
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28 |
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/METADATA
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Metadata-Version: 2.1
|
2 |
+
Name: MarkupSafe
|
3 |
+
Version: 2.1.3
|
4 |
+
Summary: Safely add untrusted strings to HTML/XML markup.
|
5 |
+
Home-page: https://palletsprojects.com/p/markupsafe/
|
6 |
+
Maintainer: Pallets
|
7 |
+
Maintainer-email: [email protected]
|
8 |
+
License: BSD-3-Clause
|
9 |
+
Project-URL: Donate, https://palletsprojects.com/donate
|
10 |
+
Project-URL: Documentation, https://markupsafe.palletsprojects.com/
|
11 |
+
Project-URL: Changes, https://markupsafe.palletsprojects.com/changes/
|
12 |
+
Project-URL: Source Code, https://github.com/pallets/markupsafe/
|
13 |
+
Project-URL: Issue Tracker, https://github.com/pallets/markupsafe/issues/
|
14 |
+
Project-URL: Chat, https://discord.gg/pallets
|
15 |
+
Classifier: Development Status :: 5 - Production/Stable
|
16 |
+
Classifier: Environment :: Web Environment
|
17 |
+
Classifier: Intended Audience :: Developers
|
18 |
+
Classifier: License :: OSI Approved :: BSD License
|
19 |
+
Classifier: Operating System :: OS Independent
|
20 |
+
Classifier: Programming Language :: Python
|
21 |
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
22 |
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
23 |
+
Requires-Python: >=3.7
|
24 |
+
Description-Content-Type: text/x-rst
|
25 |
+
License-File: LICENSE.rst
|
26 |
+
|
27 |
+
MarkupSafe
|
28 |
+
==========
|
29 |
+
|
30 |
+
MarkupSafe implements a text object that escapes characters so it is
|
31 |
+
safe to use in HTML and XML. Characters that have special meanings are
|
32 |
+
replaced so that they display as the actual characters. This mitigates
|
33 |
+
injection attacks, meaning untrusted user input can safely be displayed
|
34 |
+
on a page.
|
35 |
+
|
36 |
+
|
37 |
+
Installing
|
38 |
+
----------
|
39 |
+
|
40 |
+
Install and update using `pip`_:
|
41 |
+
|
42 |
+
.. code-block:: text
|
43 |
+
|
44 |
+
pip install -U MarkupSafe
|
45 |
+
|
46 |
+
.. _pip: https://pip.pypa.io/en/stable/getting-started/
|
47 |
+
|
48 |
+
|
49 |
+
Examples
|
50 |
+
--------
|
51 |
+
|
52 |
+
.. code-block:: pycon
|
53 |
+
|
54 |
+
>>> from markupsafe import Markup, escape
|
55 |
+
|
56 |
+
>>> # escape replaces special characters and wraps in Markup
|
57 |
+
>>> escape("<script>alert(document.cookie);</script>")
|
58 |
+
Markup('<script>alert(document.cookie);</script>')
|
59 |
+
|
60 |
+
>>> # wrap in Markup to mark text "safe" and prevent escaping
|
61 |
+
>>> Markup("<strong>Hello</strong>")
|
62 |
+
Markup('<strong>hello</strong>')
|
63 |
+
|
64 |
+
>>> escape(Markup("<strong>Hello</strong>"))
|
65 |
+
Markup('<strong>hello</strong>')
|
66 |
+
|
67 |
+
>>> # Markup is a str subclass
|
68 |
+
>>> # methods and operators escape their arguments
|
69 |
+
>>> template = Markup("Hello <em>{name}</em>")
|
70 |
+
>>> template.format(name='"World"')
|
71 |
+
Markup('Hello <em>"World"</em>')
|
72 |
+
|
73 |
+
|
74 |
+
Donate
|
75 |
+
------
|
76 |
+
|
77 |
+
The Pallets organization develops and supports MarkupSafe and other
|
78 |
+
popular packages. In order to grow the community of contributors and
|
79 |
+
users, and allow the maintainers to devote more time to the projects,
|
80 |
+
`please donate today`_.
|
81 |
+
|
82 |
+
.. _please donate today: https://palletsprojects.com/donate
|
83 |
+
|
84 |
+
|
85 |
+
Links
|
86 |
+
-----
|
87 |
+
|
88 |
+
- Documentation: https://markupsafe.palletsprojects.com/
|
89 |
+
- Changes: https://markupsafe.palletsprojects.com/changes/
|
90 |
+
- PyPI Releases: https://pypi.org/project/MarkupSafe/
|
91 |
+
- Source Code: https://github.com/pallets/markupsafe/
|
92 |
+
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
|
93 |
+
- Chat: https://discord.gg/pallets
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/RECORD
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MarkupSafe-2.1.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
2 |
+
MarkupSafe-2.1.3.dist-info/LICENSE.rst,sha256=RjHsDbX9kKVH4zaBcmTGeYIUM4FG-KyUtKV_lu6MnsQ,1503
|
3 |
+
MarkupSafe-2.1.3.dist-info/METADATA,sha256=5gU_TQw6eHpTaqkI6SPeZje6KTPlJPAV82uNiL3naKE,3096
|
4 |
+
MarkupSafe-2.1.3.dist-info/RECORD,,
|
5 |
+
MarkupSafe-2.1.3.dist-info/WHEEL,sha256=F2aDWtWrilNM3-px1vBtJOEd7aRVTetQfFuDYmYbAUQ,100
|
6 |
+
MarkupSafe-2.1.3.dist-info/top_level.txt,sha256=qy0Plje5IJuvsCBjejJyhDCjEAdcDLK_2agVcex8Z6U,11
|
7 |
+
markupsafe/__init__.py,sha256=GsRaSTjrhvg6c88PnPJNqm4MafU_mFatfXz4-h80-Qc,10642
|
8 |
+
markupsafe/__pycache__/__init__.cpython-38.pyc,,
|
9 |
+
markupsafe/__pycache__/_native.cpython-38.pyc,,
|
10 |
+
markupsafe/_native.py,sha256=_Q7UsXCOvgdonCgqG3l5asANI6eo50EKnDM-mlwEC5M,1776
|
11 |
+
markupsafe/_speedups.c,sha256=n3jzzaJwXcoN8nTFyA53f3vSqsWK2vujI-v6QYifjhQ,7403
|
12 |
+
markupsafe/_speedups.cp38-win_amd64.pyd,sha256=Khw6ew6z1NnXwsdh8VBj8-2cQWl7-DRMSaL6c1zkXhU,15872
|
13 |
+
markupsafe/_speedups.pyi,sha256=f5QtwIOP0eLrxh2v5p6SmaYmlcHIGIfmz0DovaqL0OU,238
|
14 |
+
markupsafe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/WHEEL
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Wheel-Version: 1.0
|
2 |
+
Generator: bdist_wheel (0.40.0)
|
3 |
+
Root-Is-Purelib: false
|
4 |
+
Tag: cp38-cp38-win_amd64
|
5 |
+
|
venv/Lib/site-packages/MarkupSafe-2.1.3.dist-info/top_level.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
markupsafe
|
venv/Lib/site-packages/PIL/BdfFontFile.py
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# bitmap distribution font (bdf) file parser
|
6 |
+
#
|
7 |
+
# history:
|
8 |
+
# 1996-05-16 fl created (as bdf2pil)
|
9 |
+
# 1997-08-25 fl converted to FontFile driver
|
10 |
+
# 2001-05-25 fl removed bogus __init__ call
|
11 |
+
# 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev)
|
12 |
+
# 2003-04-22 fl more robustification (from Graham Dumpleton)
|
13 |
+
#
|
14 |
+
# Copyright (c) 1997-2003 by Secret Labs AB.
|
15 |
+
# Copyright (c) 1997-2003 by Fredrik Lundh.
|
16 |
+
#
|
17 |
+
# See the README file for information on usage and redistribution.
|
18 |
+
#
|
19 |
+
|
20 |
+
"""
|
21 |
+
Parse X Bitmap Distribution Format (BDF)
|
22 |
+
"""
|
23 |
+
|
24 |
+
|
25 |
+
from . import FontFile, Image
|
26 |
+
|
27 |
+
bdf_slant = {
|
28 |
+
"R": "Roman",
|
29 |
+
"I": "Italic",
|
30 |
+
"O": "Oblique",
|
31 |
+
"RI": "Reverse Italic",
|
32 |
+
"RO": "Reverse Oblique",
|
33 |
+
"OT": "Other",
|
34 |
+
}
|
35 |
+
|
36 |
+
bdf_spacing = {"P": "Proportional", "M": "Monospaced", "C": "Cell"}
|
37 |
+
|
38 |
+
|
39 |
+
def bdf_char(f):
|
40 |
+
# skip to STARTCHAR
|
41 |
+
while True:
|
42 |
+
s = f.readline()
|
43 |
+
if not s:
|
44 |
+
return None
|
45 |
+
if s[:9] == b"STARTCHAR":
|
46 |
+
break
|
47 |
+
id = s[9:].strip().decode("ascii")
|
48 |
+
|
49 |
+
# load symbol properties
|
50 |
+
props = {}
|
51 |
+
while True:
|
52 |
+
s = f.readline()
|
53 |
+
if not s or s[:6] == b"BITMAP":
|
54 |
+
break
|
55 |
+
i = s.find(b" ")
|
56 |
+
props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")
|
57 |
+
|
58 |
+
# load bitmap
|
59 |
+
bitmap = []
|
60 |
+
while True:
|
61 |
+
s = f.readline()
|
62 |
+
if not s or s[:7] == b"ENDCHAR":
|
63 |
+
break
|
64 |
+
bitmap.append(s[:-1])
|
65 |
+
bitmap = b"".join(bitmap)
|
66 |
+
|
67 |
+
# The word BBX
|
68 |
+
# followed by the width in x (BBw), height in y (BBh),
|
69 |
+
# and x and y displacement (BBxoff0, BByoff0)
|
70 |
+
# of the lower left corner from the origin of the character.
|
71 |
+
width, height, x_disp, y_disp = (int(p) for p in props["BBX"].split())
|
72 |
+
|
73 |
+
# The word DWIDTH
|
74 |
+
# followed by the width in x and y of the character in device pixels.
|
75 |
+
dwx, dwy = (int(p) for p in props["DWIDTH"].split())
|
76 |
+
|
77 |
+
bbox = (
|
78 |
+
(dwx, dwy),
|
79 |
+
(x_disp, -y_disp - height, width + x_disp, -y_disp),
|
80 |
+
(0, 0, width, height),
|
81 |
+
)
|
82 |
+
|
83 |
+
try:
|
84 |
+
im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
|
85 |
+
except ValueError:
|
86 |
+
# deal with zero-width characters
|
87 |
+
im = Image.new("1", (width, height))
|
88 |
+
|
89 |
+
return id, int(props["ENCODING"]), bbox, im
|
90 |
+
|
91 |
+
|
92 |
+
class BdfFontFile(FontFile.FontFile):
|
93 |
+
"""Font file plugin for the X11 BDF format."""
|
94 |
+
|
95 |
+
def __init__(self, fp):
|
96 |
+
super().__init__()
|
97 |
+
|
98 |
+
s = fp.readline()
|
99 |
+
if s[:13] != b"STARTFONT 2.1":
|
100 |
+
msg = "not a valid BDF file"
|
101 |
+
raise SyntaxError(msg)
|
102 |
+
|
103 |
+
props = {}
|
104 |
+
comments = []
|
105 |
+
|
106 |
+
while True:
|
107 |
+
s = fp.readline()
|
108 |
+
if not s or s[:13] == b"ENDPROPERTIES":
|
109 |
+
break
|
110 |
+
i = s.find(b" ")
|
111 |
+
props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")
|
112 |
+
if s[:i] in [b"COMMENT", b"COPYRIGHT"]:
|
113 |
+
if s.find(b"LogicalFontDescription") < 0:
|
114 |
+
comments.append(s[i + 1 : -1].decode("ascii"))
|
115 |
+
|
116 |
+
while True:
|
117 |
+
c = bdf_char(fp)
|
118 |
+
if not c:
|
119 |
+
break
|
120 |
+
id, ch, (xy, dst, src), im = c
|
121 |
+
if 0 <= ch < len(self.glyph):
|
122 |
+
self.glyph[ch] = xy, dst, src, im
|
venv/Lib/site-packages/PIL/BlpImagePlugin.py
ADDED
@@ -0,0 +1,474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Blizzard Mipmap Format (.blp)
|
3 |
+
Jerome Leclanche <[email protected]>
|
4 |
+
|
5 |
+
The contents of this file are hereby released in the public domain (CC0)
|
6 |
+
Full text of the CC0 license:
|
7 |
+
https://creativecommons.org/publicdomain/zero/1.0/
|
8 |
+
|
9 |
+
BLP1 files, used mostly in Warcraft III, are not fully supported.
|
10 |
+
All types of BLP2 files used in World of Warcraft are supported.
|
11 |
+
|
12 |
+
The BLP file structure consists of a header, up to 16 mipmaps of the
|
13 |
+
texture
|
14 |
+
|
15 |
+
Texture sizes must be powers of two, though the two dimensions do
|
16 |
+
not have to be equal; 512x256 is valid, but 512x200 is not.
|
17 |
+
The first mipmap (mipmap #0) is the full size image; each subsequent
|
18 |
+
mipmap halves both dimensions. The final mipmap should be 1x1.
|
19 |
+
|
20 |
+
BLP files come in many different flavours:
|
21 |
+
* JPEG-compressed (type == 0) - only supported for BLP1.
|
22 |
+
* RAW images (type == 1, encoding == 1). Each mipmap is stored as an
|
23 |
+
array of 8-bit values, one per pixel, left to right, top to bottom.
|
24 |
+
Each value is an index to the palette.
|
25 |
+
* DXT-compressed (type == 1, encoding == 2):
|
26 |
+
- DXT1 compression is used if alpha_encoding == 0.
|
27 |
+
- An additional alpha bit is used if alpha_depth == 1.
|
28 |
+
- DXT3 compression is used if alpha_encoding == 1.
|
29 |
+
- DXT5 compression is used if alpha_encoding == 7.
|
30 |
+
"""
|
31 |
+
|
32 |
+
import os
|
33 |
+
import struct
|
34 |
+
from enum import IntEnum
|
35 |
+
from io import BytesIO
|
36 |
+
|
37 |
+
from . import Image, ImageFile
|
38 |
+
|
39 |
+
|
40 |
+
class Format(IntEnum):
|
41 |
+
JPEG = 0
|
42 |
+
|
43 |
+
|
44 |
+
class Encoding(IntEnum):
|
45 |
+
UNCOMPRESSED = 1
|
46 |
+
DXT = 2
|
47 |
+
UNCOMPRESSED_RAW_BGRA = 3
|
48 |
+
|
49 |
+
|
50 |
+
class AlphaEncoding(IntEnum):
|
51 |
+
DXT1 = 0
|
52 |
+
DXT3 = 1
|
53 |
+
DXT5 = 7
|
54 |
+
|
55 |
+
|
56 |
+
def unpack_565(i):
|
57 |
+
return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3
|
58 |
+
|
59 |
+
|
60 |
+
def decode_dxt1(data, alpha=False):
|
61 |
+
"""
|
62 |
+
input: one "row" of data (i.e. will produce 4*width pixels)
|
63 |
+
"""
|
64 |
+
|
65 |
+
blocks = len(data) // 8 # number of blocks in row
|
66 |
+
ret = (bytearray(), bytearray(), bytearray(), bytearray())
|
67 |
+
|
68 |
+
for block in range(blocks):
|
69 |
+
# Decode next 8-byte block.
|
70 |
+
idx = block * 8
|
71 |
+
color0, color1, bits = struct.unpack_from("<HHI", data, idx)
|
72 |
+
|
73 |
+
r0, g0, b0 = unpack_565(color0)
|
74 |
+
r1, g1, b1 = unpack_565(color1)
|
75 |
+
|
76 |
+
# Decode this block into 4x4 pixels
|
77 |
+
# Accumulate the results onto our 4 row accumulators
|
78 |
+
for j in range(4):
|
79 |
+
for i in range(4):
|
80 |
+
# get next control op and generate a pixel
|
81 |
+
|
82 |
+
control = bits & 3
|
83 |
+
bits = bits >> 2
|
84 |
+
|
85 |
+
a = 0xFF
|
86 |
+
if control == 0:
|
87 |
+
r, g, b = r0, g0, b0
|
88 |
+
elif control == 1:
|
89 |
+
r, g, b = r1, g1, b1
|
90 |
+
elif control == 2:
|
91 |
+
if color0 > color1:
|
92 |
+
r = (2 * r0 + r1) // 3
|
93 |
+
g = (2 * g0 + g1) // 3
|
94 |
+
b = (2 * b0 + b1) // 3
|
95 |
+
else:
|
96 |
+
r = (r0 + r1) // 2
|
97 |
+
g = (g0 + g1) // 2
|
98 |
+
b = (b0 + b1) // 2
|
99 |
+
elif control == 3:
|
100 |
+
if color0 > color1:
|
101 |
+
r = (2 * r1 + r0) // 3
|
102 |
+
g = (2 * g1 + g0) // 3
|
103 |
+
b = (2 * b1 + b0) // 3
|
104 |
+
else:
|
105 |
+
r, g, b, a = 0, 0, 0, 0
|
106 |
+
|
107 |
+
if alpha:
|
108 |
+
ret[j].extend([r, g, b, a])
|
109 |
+
else:
|
110 |
+
ret[j].extend([r, g, b])
|
111 |
+
|
112 |
+
return ret
|
113 |
+
|
114 |
+
|
115 |
+
def decode_dxt3(data):
|
116 |
+
"""
|
117 |
+
input: one "row" of data (i.e. will produce 4*width pixels)
|
118 |
+
"""
|
119 |
+
|
120 |
+
blocks = len(data) // 16 # number of blocks in row
|
121 |
+
ret = (bytearray(), bytearray(), bytearray(), bytearray())
|
122 |
+
|
123 |
+
for block in range(blocks):
|
124 |
+
idx = block * 16
|
125 |
+
block = data[idx : idx + 16]
|
126 |
+
# Decode next 16-byte block.
|
127 |
+
bits = struct.unpack_from("<8B", block)
|
128 |
+
color0, color1 = struct.unpack_from("<HH", block, 8)
|
129 |
+
|
130 |
+
(code,) = struct.unpack_from("<I", block, 12)
|
131 |
+
|
132 |
+
r0, g0, b0 = unpack_565(color0)
|
133 |
+
r1, g1, b1 = unpack_565(color1)
|
134 |
+
|
135 |
+
for j in range(4):
|
136 |
+
high = False # Do we want the higher bits?
|
137 |
+
for i in range(4):
|
138 |
+
alphacode_index = (4 * j + i) // 2
|
139 |
+
a = bits[alphacode_index]
|
140 |
+
if high:
|
141 |
+
high = False
|
142 |
+
a >>= 4
|
143 |
+
else:
|
144 |
+
high = True
|
145 |
+
a &= 0xF
|
146 |
+
a *= 17 # We get a value between 0 and 15
|
147 |
+
|
148 |
+
color_code = (code >> 2 * (4 * j + i)) & 0x03
|
149 |
+
|
150 |
+
if color_code == 0:
|
151 |
+
r, g, b = r0, g0, b0
|
152 |
+
elif color_code == 1:
|
153 |
+
r, g, b = r1, g1, b1
|
154 |
+
elif color_code == 2:
|
155 |
+
r = (2 * r0 + r1) // 3
|
156 |
+
g = (2 * g0 + g1) // 3
|
157 |
+
b = (2 * b0 + b1) // 3
|
158 |
+
elif color_code == 3:
|
159 |
+
r = (2 * r1 + r0) // 3
|
160 |
+
g = (2 * g1 + g0) // 3
|
161 |
+
b = (2 * b1 + b0) // 3
|
162 |
+
|
163 |
+
ret[j].extend([r, g, b, a])
|
164 |
+
|
165 |
+
return ret
|
166 |
+
|
167 |
+
|
168 |
+
def decode_dxt5(data):
|
169 |
+
"""
|
170 |
+
input: one "row" of data (i.e. will produce 4 * width pixels)
|
171 |
+
"""
|
172 |
+
|
173 |
+
blocks = len(data) // 16 # number of blocks in row
|
174 |
+
ret = (bytearray(), bytearray(), bytearray(), bytearray())
|
175 |
+
|
176 |
+
for block in range(blocks):
|
177 |
+
idx = block * 16
|
178 |
+
block = data[idx : idx + 16]
|
179 |
+
# Decode next 16-byte block.
|
180 |
+
a0, a1 = struct.unpack_from("<BB", block)
|
181 |
+
|
182 |
+
bits = struct.unpack_from("<6B", block, 2)
|
183 |
+
alphacode1 = bits[2] | (bits[3] << 8) | (bits[4] << 16) | (bits[5] << 24)
|
184 |
+
alphacode2 = bits[0] | (bits[1] << 8)
|
185 |
+
|
186 |
+
color0, color1 = struct.unpack_from("<HH", block, 8)
|
187 |
+
|
188 |
+
(code,) = struct.unpack_from("<I", block, 12)
|
189 |
+
|
190 |
+
r0, g0, b0 = unpack_565(color0)
|
191 |
+
r1, g1, b1 = unpack_565(color1)
|
192 |
+
|
193 |
+
for j in range(4):
|
194 |
+
for i in range(4):
|
195 |
+
# get next control op and generate a pixel
|
196 |
+
alphacode_index = 3 * (4 * j + i)
|
197 |
+
|
198 |
+
if alphacode_index <= 12:
|
199 |
+
alphacode = (alphacode2 >> alphacode_index) & 0x07
|
200 |
+
elif alphacode_index == 15:
|
201 |
+
alphacode = (alphacode2 >> 15) | ((alphacode1 << 1) & 0x06)
|
202 |
+
else: # alphacode_index >= 18 and alphacode_index <= 45
|
203 |
+
alphacode = (alphacode1 >> (alphacode_index - 16)) & 0x07
|
204 |
+
|
205 |
+
if alphacode == 0:
|
206 |
+
a = a0
|
207 |
+
elif alphacode == 1:
|
208 |
+
a = a1
|
209 |
+
elif a0 > a1:
|
210 |
+
a = ((8 - alphacode) * a0 + (alphacode - 1) * a1) // 7
|
211 |
+
elif alphacode == 6:
|
212 |
+
a = 0
|
213 |
+
elif alphacode == 7:
|
214 |
+
a = 255
|
215 |
+
else:
|
216 |
+
a = ((6 - alphacode) * a0 + (alphacode - 1) * a1) // 5
|
217 |
+
|
218 |
+
color_code = (code >> 2 * (4 * j + i)) & 0x03
|
219 |
+
|
220 |
+
if color_code == 0:
|
221 |
+
r, g, b = r0, g0, b0
|
222 |
+
elif color_code == 1:
|
223 |
+
r, g, b = r1, g1, b1
|
224 |
+
elif color_code == 2:
|
225 |
+
r = (2 * r0 + r1) // 3
|
226 |
+
g = (2 * g0 + g1) // 3
|
227 |
+
b = (2 * b0 + b1) // 3
|
228 |
+
elif color_code == 3:
|
229 |
+
r = (2 * r1 + r0) // 3
|
230 |
+
g = (2 * g1 + g0) // 3
|
231 |
+
b = (2 * b1 + b0) // 3
|
232 |
+
|
233 |
+
ret[j].extend([r, g, b, a])
|
234 |
+
|
235 |
+
return ret
|
236 |
+
|
237 |
+
|
238 |
+
class BLPFormatError(NotImplementedError):
|
239 |
+
pass
|
240 |
+
|
241 |
+
|
242 |
+
def _accept(prefix):
|
243 |
+
return prefix[:4] in (b"BLP1", b"BLP2")
|
244 |
+
|
245 |
+
|
246 |
+
class BlpImageFile(ImageFile.ImageFile):
|
247 |
+
"""
|
248 |
+
Blizzard Mipmap Format
|
249 |
+
"""
|
250 |
+
|
251 |
+
format = "BLP"
|
252 |
+
format_description = "Blizzard Mipmap Format"
|
253 |
+
|
254 |
+
def _open(self):
|
255 |
+
self.magic = self.fp.read(4)
|
256 |
+
|
257 |
+
self.fp.seek(5, os.SEEK_CUR)
|
258 |
+
(self._blp_alpha_depth,) = struct.unpack("<b", self.fp.read(1))
|
259 |
+
|
260 |
+
self.fp.seek(2, os.SEEK_CUR)
|
261 |
+
self._size = struct.unpack("<II", self.fp.read(8))
|
262 |
+
|
263 |
+
if self.magic in (b"BLP1", b"BLP2"):
|
264 |
+
decoder = self.magic.decode()
|
265 |
+
else:
|
266 |
+
msg = f"Bad BLP magic {repr(self.magic)}"
|
267 |
+
raise BLPFormatError(msg)
|
268 |
+
|
269 |
+
self._mode = "RGBA" if self._blp_alpha_depth else "RGB"
|
270 |
+
self.tile = [(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
|
271 |
+
|
272 |
+
|
273 |
+
class _BLPBaseDecoder(ImageFile.PyDecoder):
|
274 |
+
_pulls_fd = True
|
275 |
+
|
276 |
+
def decode(self, buffer):
|
277 |
+
try:
|
278 |
+
self._read_blp_header()
|
279 |
+
self._load()
|
280 |
+
except struct.error as e:
|
281 |
+
msg = "Truncated BLP file"
|
282 |
+
raise OSError(msg) from e
|
283 |
+
return -1, 0
|
284 |
+
|
285 |
+
def _read_blp_header(self):
|
286 |
+
self.fd.seek(4)
|
287 |
+
(self._blp_compression,) = struct.unpack("<i", self._safe_read(4))
|
288 |
+
|
289 |
+
(self._blp_encoding,) = struct.unpack("<b", self._safe_read(1))
|
290 |
+
(self._blp_alpha_depth,) = struct.unpack("<b", self._safe_read(1))
|
291 |
+
(self._blp_alpha_encoding,) = struct.unpack("<b", self._safe_read(1))
|
292 |
+
self.fd.seek(1, os.SEEK_CUR) # mips
|
293 |
+
|
294 |
+
self.size = struct.unpack("<II", self._safe_read(8))
|
295 |
+
|
296 |
+
if isinstance(self, BLP1Decoder):
|
297 |
+
# Only present for BLP1
|
298 |
+
(self._blp_encoding,) = struct.unpack("<i", self._safe_read(4))
|
299 |
+
self.fd.seek(4, os.SEEK_CUR) # subtype
|
300 |
+
|
301 |
+
self._blp_offsets = struct.unpack("<16I", self._safe_read(16 * 4))
|
302 |
+
self._blp_lengths = struct.unpack("<16I", self._safe_read(16 * 4))
|
303 |
+
|
304 |
+
def _safe_read(self, length):
|
305 |
+
return ImageFile._safe_read(self.fd, length)
|
306 |
+
|
307 |
+
def _read_palette(self):
|
308 |
+
ret = []
|
309 |
+
for i in range(256):
|
310 |
+
try:
|
311 |
+
b, g, r, a = struct.unpack("<4B", self._safe_read(4))
|
312 |
+
except struct.error:
|
313 |
+
break
|
314 |
+
ret.append((b, g, r, a))
|
315 |
+
return ret
|
316 |
+
|
317 |
+
def _read_bgra(self, palette):
|
318 |
+
data = bytearray()
|
319 |
+
_data = BytesIO(self._safe_read(self._blp_lengths[0]))
|
320 |
+
while True:
|
321 |
+
try:
|
322 |
+
(offset,) = struct.unpack("<B", _data.read(1))
|
323 |
+
except struct.error:
|
324 |
+
break
|
325 |
+
b, g, r, a = palette[offset]
|
326 |
+
d = (r, g, b)
|
327 |
+
if self._blp_alpha_depth:
|
328 |
+
d += (a,)
|
329 |
+
data.extend(d)
|
330 |
+
return data
|
331 |
+
|
332 |
+
|
333 |
+
class BLP1Decoder(_BLPBaseDecoder):
|
334 |
+
def _load(self):
|
335 |
+
if self._blp_compression == Format.JPEG:
|
336 |
+
self._decode_jpeg_stream()
|
337 |
+
|
338 |
+
elif self._blp_compression == 1:
|
339 |
+
if self._blp_encoding in (4, 5):
|
340 |
+
palette = self._read_palette()
|
341 |
+
data = self._read_bgra(palette)
|
342 |
+
self.set_as_raw(bytes(data))
|
343 |
+
else:
|
344 |
+
msg = f"Unsupported BLP encoding {repr(self._blp_encoding)}"
|
345 |
+
raise BLPFormatError(msg)
|
346 |
+
else:
|
347 |
+
msg = f"Unsupported BLP compression {repr(self._blp_encoding)}"
|
348 |
+
raise BLPFormatError(msg)
|
349 |
+
|
350 |
+
def _decode_jpeg_stream(self):
|
351 |
+
from .JpegImagePlugin import JpegImageFile
|
352 |
+
|
353 |
+
(jpeg_header_size,) = struct.unpack("<I", self._safe_read(4))
|
354 |
+
jpeg_header = self._safe_read(jpeg_header_size)
|
355 |
+
self._safe_read(self._blp_offsets[0] - self.fd.tell()) # What IS this?
|
356 |
+
data = self._safe_read(self._blp_lengths[0])
|
357 |
+
data = jpeg_header + data
|
358 |
+
data = BytesIO(data)
|
359 |
+
image = JpegImageFile(data)
|
360 |
+
Image._decompression_bomb_check(image.size)
|
361 |
+
if image.mode == "CMYK":
|
362 |
+
decoder_name, extents, offset, args = image.tile[0]
|
363 |
+
image.tile = [(decoder_name, extents, offset, (args[0], "CMYK"))]
|
364 |
+
r, g, b = image.convert("RGB").split()
|
365 |
+
image = Image.merge("RGB", (b, g, r))
|
366 |
+
self.set_as_raw(image.tobytes())
|
367 |
+
|
368 |
+
|
369 |
+
class BLP2Decoder(_BLPBaseDecoder):
|
370 |
+
def _load(self):
|
371 |
+
palette = self._read_palette()
|
372 |
+
|
373 |
+
self.fd.seek(self._blp_offsets[0])
|
374 |
+
|
375 |
+
if self._blp_compression == 1:
|
376 |
+
# Uncompressed or DirectX compression
|
377 |
+
|
378 |
+
if self._blp_encoding == Encoding.UNCOMPRESSED:
|
379 |
+
data = self._read_bgra(palette)
|
380 |
+
|
381 |
+
elif self._blp_encoding == Encoding.DXT:
|
382 |
+
data = bytearray()
|
383 |
+
if self._blp_alpha_encoding == AlphaEncoding.DXT1:
|
384 |
+
linesize = (self.size[0] + 3) // 4 * 8
|
385 |
+
for yb in range((self.size[1] + 3) // 4):
|
386 |
+
for d in decode_dxt1(
|
387 |
+
self._safe_read(linesize), alpha=bool(self._blp_alpha_depth)
|
388 |
+
):
|
389 |
+
data += d
|
390 |
+
|
391 |
+
elif self._blp_alpha_encoding == AlphaEncoding.DXT3:
|
392 |
+
linesize = (self.size[0] + 3) // 4 * 16
|
393 |
+
for yb in range((self.size[1] + 3) // 4):
|
394 |
+
for d in decode_dxt3(self._safe_read(linesize)):
|
395 |
+
data += d
|
396 |
+
|
397 |
+
elif self._blp_alpha_encoding == AlphaEncoding.DXT5:
|
398 |
+
linesize = (self.size[0] + 3) // 4 * 16
|
399 |
+
for yb in range((self.size[1] + 3) // 4):
|
400 |
+
for d in decode_dxt5(self._safe_read(linesize)):
|
401 |
+
data += d
|
402 |
+
else:
|
403 |
+
msg = f"Unsupported alpha encoding {repr(self._blp_alpha_encoding)}"
|
404 |
+
raise BLPFormatError(msg)
|
405 |
+
else:
|
406 |
+
msg = f"Unknown BLP encoding {repr(self._blp_encoding)}"
|
407 |
+
raise BLPFormatError(msg)
|
408 |
+
|
409 |
+
else:
|
410 |
+
msg = f"Unknown BLP compression {repr(self._blp_compression)}"
|
411 |
+
raise BLPFormatError(msg)
|
412 |
+
|
413 |
+
self.set_as_raw(bytes(data))
|
414 |
+
|
415 |
+
|
416 |
+
class BLPEncoder(ImageFile.PyEncoder):
|
417 |
+
_pushes_fd = True
|
418 |
+
|
419 |
+
def _write_palette(self):
|
420 |
+
data = b""
|
421 |
+
palette = self.im.getpalette("RGBA", "RGBA")
|
422 |
+
for i in range(len(palette) // 4):
|
423 |
+
r, g, b, a = palette[i * 4 : (i + 1) * 4]
|
424 |
+
data += struct.pack("<4B", b, g, r, a)
|
425 |
+
while len(data) < 256 * 4:
|
426 |
+
data += b"\x00" * 4
|
427 |
+
return data
|
428 |
+
|
429 |
+
def encode(self, bufsize):
|
430 |
+
palette_data = self._write_palette()
|
431 |
+
|
432 |
+
offset = 20 + 16 * 4 * 2 + len(palette_data)
|
433 |
+
data = struct.pack("<16I", offset, *((0,) * 15))
|
434 |
+
|
435 |
+
w, h = self.im.size
|
436 |
+
data += struct.pack("<16I", w * h, *((0,) * 15))
|
437 |
+
|
438 |
+
data += palette_data
|
439 |
+
|
440 |
+
for y in range(h):
|
441 |
+
for x in range(w):
|
442 |
+
data += struct.pack("<B", self.im.getpixel((x, y)))
|
443 |
+
|
444 |
+
return len(data), 0, data
|
445 |
+
|
446 |
+
|
447 |
+
def _save(im, fp, filename):
|
448 |
+
if im.mode != "P":
|
449 |
+
msg = "Unsupported BLP image mode"
|
450 |
+
raise ValueError(msg)
|
451 |
+
|
452 |
+
magic = b"BLP1" if im.encoderinfo.get("blp_version") == "BLP1" else b"BLP2"
|
453 |
+
fp.write(magic)
|
454 |
+
|
455 |
+
fp.write(struct.pack("<i", 1)) # Uncompressed or DirectX compression
|
456 |
+
fp.write(struct.pack("<b", Encoding.UNCOMPRESSED))
|
457 |
+
fp.write(struct.pack("<b", 1 if im.palette.mode == "RGBA" else 0))
|
458 |
+
fp.write(struct.pack("<b", 0)) # alpha encoding
|
459 |
+
fp.write(struct.pack("<b", 0)) # mips
|
460 |
+
fp.write(struct.pack("<II", *im.size))
|
461 |
+
if magic == b"BLP1":
|
462 |
+
fp.write(struct.pack("<i", 5))
|
463 |
+
fp.write(struct.pack("<i", 0))
|
464 |
+
|
465 |
+
ImageFile._save(im, fp, [("BLP", (0, 0) + im.size, 0, im.mode)])
|
466 |
+
|
467 |
+
|
468 |
+
Image.register_open(BlpImageFile.format, BlpImageFile, _accept)
|
469 |
+
Image.register_extension(BlpImageFile.format, ".blp")
|
470 |
+
Image.register_decoder("BLP1", BLP1Decoder)
|
471 |
+
Image.register_decoder("BLP2", BLP2Decoder)
|
472 |
+
|
473 |
+
Image.register_save(BlpImageFile.format, _save)
|
474 |
+
Image.register_encoder("BLP", BLPEncoder)
|
venv/Lib/site-packages/PIL/BmpImagePlugin.py
ADDED
@@ -0,0 +1,471 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# BMP file handler
|
6 |
+
#
|
7 |
+
# Windows (and OS/2) native bitmap storage format.
|
8 |
+
#
|
9 |
+
# history:
|
10 |
+
# 1995-09-01 fl Created
|
11 |
+
# 1996-04-30 fl Added save
|
12 |
+
# 1997-08-27 fl Fixed save of 1-bit images
|
13 |
+
# 1998-03-06 fl Load P images as L where possible
|
14 |
+
# 1998-07-03 fl Load P images as 1 where possible
|
15 |
+
# 1998-12-29 fl Handle small palettes
|
16 |
+
# 2002-12-30 fl Fixed load of 1-bit palette images
|
17 |
+
# 2003-04-21 fl Fixed load of 1-bit monochrome images
|
18 |
+
# 2003-04-23 fl Added limited support for BI_BITFIELDS compression
|
19 |
+
#
|
20 |
+
# Copyright (c) 1997-2003 by Secret Labs AB
|
21 |
+
# Copyright (c) 1995-2003 by Fredrik Lundh
|
22 |
+
#
|
23 |
+
# See the README file for information on usage and redistribution.
|
24 |
+
#
|
25 |
+
|
26 |
+
|
27 |
+
import os
|
28 |
+
|
29 |
+
from . import Image, ImageFile, ImagePalette
|
30 |
+
from ._binary import i16le as i16
|
31 |
+
from ._binary import i32le as i32
|
32 |
+
from ._binary import o8
|
33 |
+
from ._binary import o16le as o16
|
34 |
+
from ._binary import o32le as o32
|
35 |
+
|
36 |
+
#
|
37 |
+
# --------------------------------------------------------------------
|
38 |
+
# Read BMP file
|
39 |
+
|
40 |
+
BIT2MODE = {
|
41 |
+
# bits => mode, rawmode
|
42 |
+
1: ("P", "P;1"),
|
43 |
+
4: ("P", "P;4"),
|
44 |
+
8: ("P", "P"),
|
45 |
+
16: ("RGB", "BGR;15"),
|
46 |
+
24: ("RGB", "BGR"),
|
47 |
+
32: ("RGB", "BGRX"),
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
def _accept(prefix):
|
52 |
+
return prefix[:2] == b"BM"
|
53 |
+
|
54 |
+
|
55 |
+
def _dib_accept(prefix):
|
56 |
+
return i32(prefix) in [12, 40, 64, 108, 124]
|
57 |
+
|
58 |
+
|
59 |
+
# =============================================================================
|
60 |
+
# Image plugin for the Windows BMP format.
|
61 |
+
# =============================================================================
|
62 |
+
class BmpImageFile(ImageFile.ImageFile):
|
63 |
+
"""Image plugin for the Windows Bitmap format (BMP)"""
|
64 |
+
|
65 |
+
# ------------------------------------------------------------- Description
|
66 |
+
format_description = "Windows Bitmap"
|
67 |
+
format = "BMP"
|
68 |
+
|
69 |
+
# -------------------------------------------------- BMP Compression values
|
70 |
+
COMPRESSIONS = {"RAW": 0, "RLE8": 1, "RLE4": 2, "BITFIELDS": 3, "JPEG": 4, "PNG": 5}
|
71 |
+
for k, v in COMPRESSIONS.items():
|
72 |
+
vars()[k] = v
|
73 |
+
|
74 |
+
def _bitmap(self, header=0, offset=0):
|
75 |
+
"""Read relevant info about the BMP"""
|
76 |
+
read, seek = self.fp.read, self.fp.seek
|
77 |
+
if header:
|
78 |
+
seek(header)
|
79 |
+
# read bmp header size @offset 14 (this is part of the header size)
|
80 |
+
file_info = {"header_size": i32(read(4)), "direction": -1}
|
81 |
+
|
82 |
+
# -------------------- If requested, read header at a specific position
|
83 |
+
# read the rest of the bmp header, without its size
|
84 |
+
header_data = ImageFile._safe_read(self.fp, file_info["header_size"] - 4)
|
85 |
+
|
86 |
+
# -------------------------------------------------- IBM OS/2 Bitmap v1
|
87 |
+
# ----- This format has different offsets because of width/height types
|
88 |
+
if file_info["header_size"] == 12:
|
89 |
+
file_info["width"] = i16(header_data, 0)
|
90 |
+
file_info["height"] = i16(header_data, 2)
|
91 |
+
file_info["planes"] = i16(header_data, 4)
|
92 |
+
file_info["bits"] = i16(header_data, 6)
|
93 |
+
file_info["compression"] = self.RAW
|
94 |
+
file_info["palette_padding"] = 3
|
95 |
+
|
96 |
+
# --------------------------------------------- Windows Bitmap v2 to v5
|
97 |
+
# v3, OS/2 v2, v4, v5
|
98 |
+
elif file_info["header_size"] in (40, 64, 108, 124):
|
99 |
+
file_info["y_flip"] = header_data[7] == 0xFF
|
100 |
+
file_info["direction"] = 1 if file_info["y_flip"] else -1
|
101 |
+
file_info["width"] = i32(header_data, 0)
|
102 |
+
file_info["height"] = (
|
103 |
+
i32(header_data, 4)
|
104 |
+
if not file_info["y_flip"]
|
105 |
+
else 2**32 - i32(header_data, 4)
|
106 |
+
)
|
107 |
+
file_info["planes"] = i16(header_data, 8)
|
108 |
+
file_info["bits"] = i16(header_data, 10)
|
109 |
+
file_info["compression"] = i32(header_data, 12)
|
110 |
+
# byte size of pixel data
|
111 |
+
file_info["data_size"] = i32(header_data, 16)
|
112 |
+
file_info["pixels_per_meter"] = (
|
113 |
+
i32(header_data, 20),
|
114 |
+
i32(header_data, 24),
|
115 |
+
)
|
116 |
+
file_info["colors"] = i32(header_data, 28)
|
117 |
+
file_info["palette_padding"] = 4
|
118 |
+
self.info["dpi"] = tuple(x / 39.3701 for x in file_info["pixels_per_meter"])
|
119 |
+
if file_info["compression"] == self.BITFIELDS:
|
120 |
+
if len(header_data) >= 52:
|
121 |
+
for idx, mask in enumerate(
|
122 |
+
["r_mask", "g_mask", "b_mask", "a_mask"]
|
123 |
+
):
|
124 |
+
file_info[mask] = i32(header_data, 36 + idx * 4)
|
125 |
+
else:
|
126 |
+
# 40 byte headers only have the three components in the
|
127 |
+
# bitfields masks, ref:
|
128 |
+
# https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
|
129 |
+
# See also
|
130 |
+
# https://github.com/python-pillow/Pillow/issues/1293
|
131 |
+
# There is a 4th component in the RGBQuad, in the alpha
|
132 |
+
# location, but it is listed as a reserved component,
|
133 |
+
# and it is not generally an alpha channel
|
134 |
+
file_info["a_mask"] = 0x0
|
135 |
+
for mask in ["r_mask", "g_mask", "b_mask"]:
|
136 |
+
file_info[mask] = i32(read(4))
|
137 |
+
file_info["rgb_mask"] = (
|
138 |
+
file_info["r_mask"],
|
139 |
+
file_info["g_mask"],
|
140 |
+
file_info["b_mask"],
|
141 |
+
)
|
142 |
+
file_info["rgba_mask"] = (
|
143 |
+
file_info["r_mask"],
|
144 |
+
file_info["g_mask"],
|
145 |
+
file_info["b_mask"],
|
146 |
+
file_info["a_mask"],
|
147 |
+
)
|
148 |
+
else:
|
149 |
+
msg = f"Unsupported BMP header type ({file_info['header_size']})"
|
150 |
+
raise OSError(msg)
|
151 |
+
|
152 |
+
# ------------------ Special case : header is reported 40, which
|
153 |
+
# ---------------------- is shorter than real size for bpp >= 16
|
154 |
+
self._size = file_info["width"], file_info["height"]
|
155 |
+
|
156 |
+
# ------- If color count was not found in the header, compute from bits
|
157 |
+
file_info["colors"] = (
|
158 |
+
file_info["colors"]
|
159 |
+
if file_info.get("colors", 0)
|
160 |
+
else (1 << file_info["bits"])
|
161 |
+
)
|
162 |
+
if offset == 14 + file_info["header_size"] and file_info["bits"] <= 8:
|
163 |
+
offset += 4 * file_info["colors"]
|
164 |
+
|
165 |
+
# ---------------------- Check bit depth for unusual unsupported values
|
166 |
+
self._mode, raw_mode = BIT2MODE.get(file_info["bits"], (None, None))
|
167 |
+
if self.mode is None:
|
168 |
+
msg = f"Unsupported BMP pixel depth ({file_info['bits']})"
|
169 |
+
raise OSError(msg)
|
170 |
+
|
171 |
+
# ---------------- Process BMP with Bitfields compression (not palette)
|
172 |
+
decoder_name = "raw"
|
173 |
+
if file_info["compression"] == self.BITFIELDS:
|
174 |
+
SUPPORTED = {
|
175 |
+
32: [
|
176 |
+
(0xFF0000, 0xFF00, 0xFF, 0x0),
|
177 |
+
(0xFF000000, 0xFF0000, 0xFF00, 0x0),
|
178 |
+
(0xFF000000, 0xFF0000, 0xFF00, 0xFF),
|
179 |
+
(0xFF, 0xFF00, 0xFF0000, 0xFF000000),
|
180 |
+
(0xFF0000, 0xFF00, 0xFF, 0xFF000000),
|
181 |
+
(0x0, 0x0, 0x0, 0x0),
|
182 |
+
],
|
183 |
+
24: [(0xFF0000, 0xFF00, 0xFF)],
|
184 |
+
16: [(0xF800, 0x7E0, 0x1F), (0x7C00, 0x3E0, 0x1F)],
|
185 |
+
}
|
186 |
+
MASK_MODES = {
|
187 |
+
(32, (0xFF0000, 0xFF00, 0xFF, 0x0)): "BGRX",
|
188 |
+
(32, (0xFF000000, 0xFF0000, 0xFF00, 0x0)): "XBGR",
|
189 |
+
(32, (0xFF000000, 0xFF0000, 0xFF00, 0xFF)): "ABGR",
|
190 |
+
(32, (0xFF, 0xFF00, 0xFF0000, 0xFF000000)): "RGBA",
|
191 |
+
(32, (0xFF0000, 0xFF00, 0xFF, 0xFF000000)): "BGRA",
|
192 |
+
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
|
193 |
+
(24, (0xFF0000, 0xFF00, 0xFF)): "BGR",
|
194 |
+
(16, (0xF800, 0x7E0, 0x1F)): "BGR;16",
|
195 |
+
(16, (0x7C00, 0x3E0, 0x1F)): "BGR;15",
|
196 |
+
}
|
197 |
+
if file_info["bits"] in SUPPORTED:
|
198 |
+
if (
|
199 |
+
file_info["bits"] == 32
|
200 |
+
and file_info["rgba_mask"] in SUPPORTED[file_info["bits"]]
|
201 |
+
):
|
202 |
+
raw_mode = MASK_MODES[(file_info["bits"], file_info["rgba_mask"])]
|
203 |
+
self._mode = "RGBA" if "A" in raw_mode else self.mode
|
204 |
+
elif (
|
205 |
+
file_info["bits"] in (24, 16)
|
206 |
+
and file_info["rgb_mask"] in SUPPORTED[file_info["bits"]]
|
207 |
+
):
|
208 |
+
raw_mode = MASK_MODES[(file_info["bits"], file_info["rgb_mask"])]
|
209 |
+
else:
|
210 |
+
msg = "Unsupported BMP bitfields layout"
|
211 |
+
raise OSError(msg)
|
212 |
+
else:
|
213 |
+
msg = "Unsupported BMP bitfields layout"
|
214 |
+
raise OSError(msg)
|
215 |
+
elif file_info["compression"] == self.RAW:
|
216 |
+
if file_info["bits"] == 32 and header == 22: # 32-bit .cur offset
|
217 |
+
raw_mode, self._mode = "BGRA", "RGBA"
|
218 |
+
elif file_info["compression"] in (self.RLE8, self.RLE4):
|
219 |
+
decoder_name = "bmp_rle"
|
220 |
+
else:
|
221 |
+
msg = f"Unsupported BMP compression ({file_info['compression']})"
|
222 |
+
raise OSError(msg)
|
223 |
+
|
224 |
+
# --------------- Once the header is processed, process the palette/LUT
|
225 |
+
if self.mode == "P": # Paletted for 1, 4 and 8 bit images
|
226 |
+
# ---------------------------------------------------- 1-bit images
|
227 |
+
if not (0 < file_info["colors"] <= 65536):
|
228 |
+
msg = f"Unsupported BMP Palette size ({file_info['colors']})"
|
229 |
+
raise OSError(msg)
|
230 |
+
else:
|
231 |
+
padding = file_info["palette_padding"]
|
232 |
+
palette = read(padding * file_info["colors"])
|
233 |
+
greyscale = True
|
234 |
+
indices = (
|
235 |
+
(0, 255)
|
236 |
+
if file_info["colors"] == 2
|
237 |
+
else list(range(file_info["colors"]))
|
238 |
+
)
|
239 |
+
|
240 |
+
# ----------------- Check if greyscale and ignore palette if so
|
241 |
+
for ind, val in enumerate(indices):
|
242 |
+
rgb = palette[ind * padding : ind * padding + 3]
|
243 |
+
if rgb != o8(val) * 3:
|
244 |
+
greyscale = False
|
245 |
+
|
246 |
+
# ------- If all colors are grey, white or black, ditch palette
|
247 |
+
if greyscale:
|
248 |
+
self._mode = "1" if file_info["colors"] == 2 else "L"
|
249 |
+
raw_mode = self.mode
|
250 |
+
else:
|
251 |
+
self._mode = "P"
|
252 |
+
self.palette = ImagePalette.raw(
|
253 |
+
"BGRX" if padding == 4 else "BGR", palette
|
254 |
+
)
|
255 |
+
|
256 |
+
# ---------------------------- Finally set the tile data for the plugin
|
257 |
+
self.info["compression"] = file_info["compression"]
|
258 |
+
args = [raw_mode]
|
259 |
+
if decoder_name == "bmp_rle":
|
260 |
+
args.append(file_info["compression"] == self.RLE4)
|
261 |
+
else:
|
262 |
+
args.append(((file_info["width"] * file_info["bits"] + 31) >> 3) & (~3))
|
263 |
+
args.append(file_info["direction"])
|
264 |
+
self.tile = [
|
265 |
+
(
|
266 |
+
decoder_name,
|
267 |
+
(0, 0, file_info["width"], file_info["height"]),
|
268 |
+
offset or self.fp.tell(),
|
269 |
+
tuple(args),
|
270 |
+
)
|
271 |
+
]
|
272 |
+
|
273 |
+
def _open(self):
|
274 |
+
"""Open file, check magic number and read header"""
|
275 |
+
# read 14 bytes: magic number, filesize, reserved, header final offset
|
276 |
+
head_data = self.fp.read(14)
|
277 |
+
# choke if the file does not have the required magic bytes
|
278 |
+
if not _accept(head_data):
|
279 |
+
msg = "Not a BMP file"
|
280 |
+
raise SyntaxError(msg)
|
281 |
+
# read the start position of the BMP image data (u32)
|
282 |
+
offset = i32(head_data, 10)
|
283 |
+
# load bitmap information (offset=raster info)
|
284 |
+
self._bitmap(offset=offset)
|
285 |
+
|
286 |
+
|
287 |
+
class BmpRleDecoder(ImageFile.PyDecoder):
|
288 |
+
_pulls_fd = True
|
289 |
+
|
290 |
+
def decode(self, buffer):
|
291 |
+
rle4 = self.args[1]
|
292 |
+
data = bytearray()
|
293 |
+
x = 0
|
294 |
+
while len(data) < self.state.xsize * self.state.ysize:
|
295 |
+
pixels = self.fd.read(1)
|
296 |
+
byte = self.fd.read(1)
|
297 |
+
if not pixels or not byte:
|
298 |
+
break
|
299 |
+
num_pixels = pixels[0]
|
300 |
+
if num_pixels:
|
301 |
+
# encoded mode
|
302 |
+
if x + num_pixels > self.state.xsize:
|
303 |
+
# Too much data for row
|
304 |
+
num_pixels = max(0, self.state.xsize - x)
|
305 |
+
if rle4:
|
306 |
+
first_pixel = o8(byte[0] >> 4)
|
307 |
+
second_pixel = o8(byte[0] & 0x0F)
|
308 |
+
for index in range(num_pixels):
|
309 |
+
if index % 2 == 0:
|
310 |
+
data += first_pixel
|
311 |
+
else:
|
312 |
+
data += second_pixel
|
313 |
+
else:
|
314 |
+
data += byte * num_pixels
|
315 |
+
x += num_pixels
|
316 |
+
else:
|
317 |
+
if byte[0] == 0:
|
318 |
+
# end of line
|
319 |
+
while len(data) % self.state.xsize != 0:
|
320 |
+
data += b"\x00"
|
321 |
+
x = 0
|
322 |
+
elif byte[0] == 1:
|
323 |
+
# end of bitmap
|
324 |
+
break
|
325 |
+
elif byte[0] == 2:
|
326 |
+
# delta
|
327 |
+
bytes_read = self.fd.read(2)
|
328 |
+
if len(bytes_read) < 2:
|
329 |
+
break
|
330 |
+
right, up = self.fd.read(2)
|
331 |
+
data += b"\x00" * (right + up * self.state.xsize)
|
332 |
+
x = len(data) % self.state.xsize
|
333 |
+
else:
|
334 |
+
# absolute mode
|
335 |
+
if rle4:
|
336 |
+
# 2 pixels per byte
|
337 |
+
byte_count = byte[0] // 2
|
338 |
+
bytes_read = self.fd.read(byte_count)
|
339 |
+
for byte_read in bytes_read:
|
340 |
+
data += o8(byte_read >> 4)
|
341 |
+
data += o8(byte_read & 0x0F)
|
342 |
+
else:
|
343 |
+
byte_count = byte[0]
|
344 |
+
bytes_read = self.fd.read(byte_count)
|
345 |
+
data += bytes_read
|
346 |
+
if len(bytes_read) < byte_count:
|
347 |
+
break
|
348 |
+
x += byte[0]
|
349 |
+
|
350 |
+
# align to 16-bit word boundary
|
351 |
+
if self.fd.tell() % 2 != 0:
|
352 |
+
self.fd.seek(1, os.SEEK_CUR)
|
353 |
+
rawmode = "L" if self.mode == "L" else "P"
|
354 |
+
self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1]))
|
355 |
+
return -1, 0
|
356 |
+
|
357 |
+
|
358 |
+
# =============================================================================
|
359 |
+
# Image plugin for the DIB format (BMP alias)
|
360 |
+
# =============================================================================
|
361 |
+
class DibImageFile(BmpImageFile):
|
362 |
+
format = "DIB"
|
363 |
+
format_description = "Windows Bitmap"
|
364 |
+
|
365 |
+
def _open(self):
|
366 |
+
self._bitmap()
|
367 |
+
|
368 |
+
|
369 |
+
#
|
370 |
+
# --------------------------------------------------------------------
|
371 |
+
# Write BMP file
|
372 |
+
|
373 |
+
|
374 |
+
SAVE = {
|
375 |
+
"1": ("1", 1, 2),
|
376 |
+
"L": ("L", 8, 256),
|
377 |
+
"P": ("P", 8, 256),
|
378 |
+
"RGB": ("BGR", 24, 0),
|
379 |
+
"RGBA": ("BGRA", 32, 0),
|
380 |
+
}
|
381 |
+
|
382 |
+
|
383 |
+
def _dib_save(im, fp, filename):
|
384 |
+
_save(im, fp, filename, False)
|
385 |
+
|
386 |
+
|
387 |
+
def _save(im, fp, filename, bitmap_header=True):
|
388 |
+
try:
|
389 |
+
rawmode, bits, colors = SAVE[im.mode]
|
390 |
+
except KeyError as e:
|
391 |
+
msg = f"cannot write mode {im.mode} as BMP"
|
392 |
+
raise OSError(msg) from e
|
393 |
+
|
394 |
+
info = im.encoderinfo
|
395 |
+
|
396 |
+
dpi = info.get("dpi", (96, 96))
|
397 |
+
|
398 |
+
# 1 meter == 39.3701 inches
|
399 |
+
ppm = tuple(map(lambda x: int(x * 39.3701 + 0.5), dpi))
|
400 |
+
|
401 |
+
stride = ((im.size[0] * bits + 7) // 8 + 3) & (~3)
|
402 |
+
header = 40 # or 64 for OS/2 version 2
|
403 |
+
image = stride * im.size[1]
|
404 |
+
|
405 |
+
if im.mode == "1":
|
406 |
+
palette = b"".join(o8(i) * 4 for i in (0, 255))
|
407 |
+
elif im.mode == "L":
|
408 |
+
palette = b"".join(o8(i) * 4 for i in range(256))
|
409 |
+
elif im.mode == "P":
|
410 |
+
palette = im.im.getpalette("RGB", "BGRX")
|
411 |
+
colors = len(palette) // 4
|
412 |
+
else:
|
413 |
+
palette = None
|
414 |
+
|
415 |
+
# bitmap header
|
416 |
+
if bitmap_header:
|
417 |
+
offset = 14 + header + colors * 4
|
418 |
+
file_size = offset + image
|
419 |
+
if file_size > 2**32 - 1:
|
420 |
+
msg = "File size is too large for the BMP format"
|
421 |
+
raise ValueError(msg)
|
422 |
+
fp.write(
|
423 |
+
b"BM" # file type (magic)
|
424 |
+
+ o32(file_size) # file size
|
425 |
+
+ o32(0) # reserved
|
426 |
+
+ o32(offset) # image data offset
|
427 |
+
)
|
428 |
+
|
429 |
+
# bitmap info header
|
430 |
+
fp.write(
|
431 |
+
o32(header) # info header size
|
432 |
+
+ o32(im.size[0]) # width
|
433 |
+
+ o32(im.size[1]) # height
|
434 |
+
+ o16(1) # planes
|
435 |
+
+ o16(bits) # depth
|
436 |
+
+ o32(0) # compression (0=uncompressed)
|
437 |
+
+ o32(image) # size of bitmap
|
438 |
+
+ o32(ppm[0]) # resolution
|
439 |
+
+ o32(ppm[1]) # resolution
|
440 |
+
+ o32(colors) # colors used
|
441 |
+
+ o32(colors) # colors important
|
442 |
+
)
|
443 |
+
|
444 |
+
fp.write(b"\0" * (header - 40)) # padding (for OS/2 format)
|
445 |
+
|
446 |
+
if palette:
|
447 |
+
fp.write(palette)
|
448 |
+
|
449 |
+
ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, stride, -1))])
|
450 |
+
|
451 |
+
|
452 |
+
#
|
453 |
+
# --------------------------------------------------------------------
|
454 |
+
# Registry
|
455 |
+
|
456 |
+
|
457 |
+
Image.register_open(BmpImageFile.format, BmpImageFile, _accept)
|
458 |
+
Image.register_save(BmpImageFile.format, _save)
|
459 |
+
|
460 |
+
Image.register_extension(BmpImageFile.format, ".bmp")
|
461 |
+
|
462 |
+
Image.register_mime(BmpImageFile.format, "image/bmp")
|
463 |
+
|
464 |
+
Image.register_decoder("bmp_rle", BmpRleDecoder)
|
465 |
+
|
466 |
+
Image.register_open(DibImageFile.format, DibImageFile, _dib_accept)
|
467 |
+
Image.register_save(DibImageFile.format, _dib_save)
|
468 |
+
|
469 |
+
Image.register_extension(DibImageFile.format, ".dib")
|
470 |
+
|
471 |
+
Image.register_mime(DibImageFile.format, "image/bmp")
|
venv/Lib/site-packages/PIL/BufrStubImagePlugin.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# BUFR stub adapter
|
6 |
+
#
|
7 |
+
# Copyright (c) 1996-2003 by Fredrik Lundh
|
8 |
+
#
|
9 |
+
# See the README file for information on usage and redistribution.
|
10 |
+
#
|
11 |
+
|
12 |
+
from . import Image, ImageFile
|
13 |
+
|
14 |
+
_handler = None
|
15 |
+
|
16 |
+
|
17 |
+
def register_handler(handler):
|
18 |
+
"""
|
19 |
+
Install application-specific BUFR image handler.
|
20 |
+
|
21 |
+
:param handler: Handler object.
|
22 |
+
"""
|
23 |
+
global _handler
|
24 |
+
_handler = handler
|
25 |
+
|
26 |
+
|
27 |
+
# --------------------------------------------------------------------
|
28 |
+
# Image adapter
|
29 |
+
|
30 |
+
|
31 |
+
def _accept(prefix):
|
32 |
+
return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC"
|
33 |
+
|
34 |
+
|
35 |
+
class BufrStubImageFile(ImageFile.StubImageFile):
|
36 |
+
format = "BUFR"
|
37 |
+
format_description = "BUFR"
|
38 |
+
|
39 |
+
def _open(self):
|
40 |
+
offset = self.fp.tell()
|
41 |
+
|
42 |
+
if not _accept(self.fp.read(4)):
|
43 |
+
msg = "Not a BUFR file"
|
44 |
+
raise SyntaxError(msg)
|
45 |
+
|
46 |
+
self.fp.seek(offset)
|
47 |
+
|
48 |
+
# make something up
|
49 |
+
self._mode = "F"
|
50 |
+
self._size = 1, 1
|
51 |
+
|
52 |
+
loader = self._load()
|
53 |
+
if loader:
|
54 |
+
loader.open(self)
|
55 |
+
|
56 |
+
def _load(self):
|
57 |
+
return _handler
|
58 |
+
|
59 |
+
|
60 |
+
def _save(im, fp, filename):
|
61 |
+
if _handler is None or not hasattr(_handler, "save"):
|
62 |
+
msg = "BUFR save handler not installed"
|
63 |
+
raise OSError(msg)
|
64 |
+
_handler.save(im, fp, filename)
|
65 |
+
|
66 |
+
|
67 |
+
# --------------------------------------------------------------------
|
68 |
+
# Registry
|
69 |
+
|
70 |
+
Image.register_open(BufrStubImageFile.format, BufrStubImageFile, _accept)
|
71 |
+
Image.register_save(BufrStubImageFile.format, _save)
|
72 |
+
|
73 |
+
Image.register_extension(BufrStubImageFile.format, ".bufr")
|
venv/Lib/site-packages/PIL/ContainerIO.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# a class to read from a container file
|
6 |
+
#
|
7 |
+
# History:
|
8 |
+
# 1995-06-18 fl Created
|
9 |
+
# 1995-09-07 fl Added readline(), readlines()
|
10 |
+
#
|
11 |
+
# Copyright (c) 1997-2001 by Secret Labs AB
|
12 |
+
# Copyright (c) 1995 by Fredrik Lundh
|
13 |
+
#
|
14 |
+
# See the README file for information on usage and redistribution.
|
15 |
+
#
|
16 |
+
|
17 |
+
|
18 |
+
import io
|
19 |
+
|
20 |
+
|
21 |
+
class ContainerIO:
|
22 |
+
"""
|
23 |
+
A file object that provides read access to a part of an existing
|
24 |
+
file (for example a TAR file).
|
25 |
+
"""
|
26 |
+
|
27 |
+
def __init__(self, file, offset, length):
|
28 |
+
"""
|
29 |
+
Create file object.
|
30 |
+
|
31 |
+
:param file: Existing file.
|
32 |
+
:param offset: Start of region, in bytes.
|
33 |
+
:param length: Size of region, in bytes.
|
34 |
+
"""
|
35 |
+
self.fh = file
|
36 |
+
self.pos = 0
|
37 |
+
self.offset = offset
|
38 |
+
self.length = length
|
39 |
+
self.fh.seek(offset)
|
40 |
+
|
41 |
+
##
|
42 |
+
# Always false.
|
43 |
+
|
44 |
+
def isatty(self):
|
45 |
+
return False
|
46 |
+
|
47 |
+
def seek(self, offset, mode=io.SEEK_SET):
|
48 |
+
"""
|
49 |
+
Move file pointer.
|
50 |
+
|
51 |
+
:param offset: Offset in bytes.
|
52 |
+
:param mode: Starting position. Use 0 for beginning of region, 1
|
53 |
+
for current offset, and 2 for end of region. You cannot move
|
54 |
+
the pointer outside the defined region.
|
55 |
+
"""
|
56 |
+
if mode == 1:
|
57 |
+
self.pos = self.pos + offset
|
58 |
+
elif mode == 2:
|
59 |
+
self.pos = self.length + offset
|
60 |
+
else:
|
61 |
+
self.pos = offset
|
62 |
+
# clamp
|
63 |
+
self.pos = max(0, min(self.pos, self.length))
|
64 |
+
self.fh.seek(self.offset + self.pos)
|
65 |
+
|
66 |
+
def tell(self):
|
67 |
+
"""
|
68 |
+
Get current file pointer.
|
69 |
+
|
70 |
+
:returns: Offset from start of region, in bytes.
|
71 |
+
"""
|
72 |
+
return self.pos
|
73 |
+
|
74 |
+
def read(self, n=0):
|
75 |
+
"""
|
76 |
+
Read data.
|
77 |
+
|
78 |
+
:param n: Number of bytes to read. If omitted or zero,
|
79 |
+
read until end of region.
|
80 |
+
:returns: An 8-bit string.
|
81 |
+
"""
|
82 |
+
if n:
|
83 |
+
n = min(n, self.length - self.pos)
|
84 |
+
else:
|
85 |
+
n = self.length - self.pos
|
86 |
+
if not n: # EOF
|
87 |
+
return b"" if "b" in self.fh.mode else ""
|
88 |
+
self.pos = self.pos + n
|
89 |
+
return self.fh.read(n)
|
90 |
+
|
91 |
+
def readline(self):
|
92 |
+
"""
|
93 |
+
Read a line of text.
|
94 |
+
|
95 |
+
:returns: An 8-bit string.
|
96 |
+
"""
|
97 |
+
s = b"" if "b" in self.fh.mode else ""
|
98 |
+
newline_character = b"\n" if "b" in self.fh.mode else "\n"
|
99 |
+
while True:
|
100 |
+
c = self.read(1)
|
101 |
+
if not c:
|
102 |
+
break
|
103 |
+
s = s + c
|
104 |
+
if c == newline_character:
|
105 |
+
break
|
106 |
+
return s
|
107 |
+
|
108 |
+
def readlines(self):
|
109 |
+
"""
|
110 |
+
Read multiple lines of text.
|
111 |
+
|
112 |
+
:returns: A list of 8-bit strings.
|
113 |
+
"""
|
114 |
+
lines = []
|
115 |
+
while True:
|
116 |
+
s = self.readline()
|
117 |
+
if not s:
|
118 |
+
break
|
119 |
+
lines.append(s)
|
120 |
+
return lines
|
venv/Lib/site-packages/PIL/CurImagePlugin.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# Windows Cursor support for PIL
|
6 |
+
#
|
7 |
+
# notes:
|
8 |
+
# uses BmpImagePlugin.py to read the bitmap data.
|
9 |
+
#
|
10 |
+
# history:
|
11 |
+
# 96-05-27 fl Created
|
12 |
+
#
|
13 |
+
# Copyright (c) Secret Labs AB 1997.
|
14 |
+
# Copyright (c) Fredrik Lundh 1996.
|
15 |
+
#
|
16 |
+
# See the README file for information on usage and redistribution.
|
17 |
+
#
|
18 |
+
from . import BmpImagePlugin, Image
|
19 |
+
from ._binary import i16le as i16
|
20 |
+
from ._binary import i32le as i32
|
21 |
+
|
22 |
+
#
|
23 |
+
# --------------------------------------------------------------------
|
24 |
+
|
25 |
+
|
26 |
+
def _accept(prefix):
|
27 |
+
return prefix[:4] == b"\0\0\2\0"
|
28 |
+
|
29 |
+
|
30 |
+
##
|
31 |
+
# Image plugin for Windows Cursor files.
|
32 |
+
|
33 |
+
|
34 |
+
class CurImageFile(BmpImagePlugin.BmpImageFile):
|
35 |
+
format = "CUR"
|
36 |
+
format_description = "Windows Cursor"
|
37 |
+
|
38 |
+
def _open(self):
|
39 |
+
offset = self.fp.tell()
|
40 |
+
|
41 |
+
# check magic
|
42 |
+
s = self.fp.read(6)
|
43 |
+
if not _accept(s):
|
44 |
+
msg = "not a CUR file"
|
45 |
+
raise SyntaxError(msg)
|
46 |
+
|
47 |
+
# pick the largest cursor in the file
|
48 |
+
m = b""
|
49 |
+
for i in range(i16(s, 4)):
|
50 |
+
s = self.fp.read(16)
|
51 |
+
if not m:
|
52 |
+
m = s
|
53 |
+
elif s[0] > m[0] and s[1] > m[1]:
|
54 |
+
m = s
|
55 |
+
if not m:
|
56 |
+
msg = "No cursors were found"
|
57 |
+
raise TypeError(msg)
|
58 |
+
|
59 |
+
# load as bitmap
|
60 |
+
self._bitmap(i32(m, 12) + offset)
|
61 |
+
|
62 |
+
# patch up the bitmap height
|
63 |
+
self._size = self.size[0], self.size[1] // 2
|
64 |
+
d, e, o, a = self.tile[0]
|
65 |
+
self.tile[0] = d, (0, 0) + self.size, o, a
|
66 |
+
|
67 |
+
return
|
68 |
+
|
69 |
+
|
70 |
+
#
|
71 |
+
# --------------------------------------------------------------------
|
72 |
+
|
73 |
+
Image.register_open(CurImageFile.format, CurImageFile, _accept)
|
74 |
+
|
75 |
+
Image.register_extension(CurImageFile.format, ".cur")
|
venv/Lib/site-packages/PIL/DcxImagePlugin.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# DCX file handling
|
6 |
+
#
|
7 |
+
# DCX is a container file format defined by Intel, commonly used
|
8 |
+
# for fax applications. Each DCX file consists of a directory
|
9 |
+
# (a list of file offsets) followed by a set of (usually 1-bit)
|
10 |
+
# PCX files.
|
11 |
+
#
|
12 |
+
# History:
|
13 |
+
# 1995-09-09 fl Created
|
14 |
+
# 1996-03-20 fl Properly derived from PcxImageFile.
|
15 |
+
# 1998-07-15 fl Renamed offset attribute to avoid name clash
|
16 |
+
# 2002-07-30 fl Fixed file handling
|
17 |
+
#
|
18 |
+
# Copyright (c) 1997-98 by Secret Labs AB.
|
19 |
+
# Copyright (c) 1995-96 by Fredrik Lundh.
|
20 |
+
#
|
21 |
+
# See the README file for information on usage and redistribution.
|
22 |
+
#
|
23 |
+
|
24 |
+
from . import Image
|
25 |
+
from ._binary import i32le as i32
|
26 |
+
from .PcxImagePlugin import PcxImageFile
|
27 |
+
|
28 |
+
MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
|
29 |
+
|
30 |
+
|
31 |
+
def _accept(prefix):
|
32 |
+
return len(prefix) >= 4 and i32(prefix) == MAGIC
|
33 |
+
|
34 |
+
|
35 |
+
##
|
36 |
+
# Image plugin for the Intel DCX format.
|
37 |
+
|
38 |
+
|
39 |
+
class DcxImageFile(PcxImageFile):
|
40 |
+
format = "DCX"
|
41 |
+
format_description = "Intel DCX"
|
42 |
+
_close_exclusive_fp_after_loading = False
|
43 |
+
|
44 |
+
def _open(self):
|
45 |
+
# Header
|
46 |
+
s = self.fp.read(4)
|
47 |
+
if not _accept(s):
|
48 |
+
msg = "not a DCX file"
|
49 |
+
raise SyntaxError(msg)
|
50 |
+
|
51 |
+
# Component directory
|
52 |
+
self._offset = []
|
53 |
+
for i in range(1024):
|
54 |
+
offset = i32(self.fp.read(4))
|
55 |
+
if not offset:
|
56 |
+
break
|
57 |
+
self._offset.append(offset)
|
58 |
+
|
59 |
+
self._fp = self.fp
|
60 |
+
self.frame = None
|
61 |
+
self.n_frames = len(self._offset)
|
62 |
+
self.is_animated = self.n_frames > 1
|
63 |
+
self.seek(0)
|
64 |
+
|
65 |
+
def seek(self, frame):
|
66 |
+
if not self._seek_check(frame):
|
67 |
+
return
|
68 |
+
self.frame = frame
|
69 |
+
self.fp = self._fp
|
70 |
+
self.fp.seek(self._offset[frame])
|
71 |
+
PcxImageFile._open(self)
|
72 |
+
|
73 |
+
def tell(self):
|
74 |
+
return self.frame
|
75 |
+
|
76 |
+
|
77 |
+
Image.register_open(DcxImageFile.format, DcxImageFile, _accept)
|
78 |
+
|
79 |
+
Image.register_extension(DcxImageFile.format, ".dcx")
|
venv/Lib/site-packages/PIL/DdsImagePlugin.py
ADDED
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
A Pillow loader for .dds files (S3TC-compressed aka DXTC)
|
3 |
+
Jerome Leclanche <[email protected]>
|
4 |
+
|
5 |
+
Documentation:
|
6 |
+
https://web.archive.org/web/20170802060935/http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt
|
7 |
+
|
8 |
+
The contents of this file are hereby released in the public domain (CC0)
|
9 |
+
Full text of the CC0 license:
|
10 |
+
https://creativecommons.org/publicdomain/zero/1.0/
|
11 |
+
"""
|
12 |
+
|
13 |
+
import struct
|
14 |
+
from io import BytesIO
|
15 |
+
|
16 |
+
from . import Image, ImageFile, ImagePalette
|
17 |
+
from ._binary import o32le as o32
|
18 |
+
|
19 |
+
# Magic ("DDS ")
|
20 |
+
DDS_MAGIC = 0x20534444
|
21 |
+
|
22 |
+
# DDS flags
|
23 |
+
DDSD_CAPS = 0x1
|
24 |
+
DDSD_HEIGHT = 0x2
|
25 |
+
DDSD_WIDTH = 0x4
|
26 |
+
DDSD_PITCH = 0x8
|
27 |
+
DDSD_PIXELFORMAT = 0x1000
|
28 |
+
DDSD_MIPMAPCOUNT = 0x20000
|
29 |
+
DDSD_LINEARSIZE = 0x80000
|
30 |
+
DDSD_DEPTH = 0x800000
|
31 |
+
|
32 |
+
# DDS caps
|
33 |
+
DDSCAPS_COMPLEX = 0x8
|
34 |
+
DDSCAPS_TEXTURE = 0x1000
|
35 |
+
DDSCAPS_MIPMAP = 0x400000
|
36 |
+
|
37 |
+
DDSCAPS2_CUBEMAP = 0x200
|
38 |
+
DDSCAPS2_CUBEMAP_POSITIVEX = 0x400
|
39 |
+
DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800
|
40 |
+
DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000
|
41 |
+
DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000
|
42 |
+
DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000
|
43 |
+
DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000
|
44 |
+
DDSCAPS2_VOLUME = 0x200000
|
45 |
+
|
46 |
+
# Pixel Format
|
47 |
+
DDPF_ALPHAPIXELS = 0x1
|
48 |
+
DDPF_ALPHA = 0x2
|
49 |
+
DDPF_FOURCC = 0x4
|
50 |
+
DDPF_PALETTEINDEXED8 = 0x20
|
51 |
+
DDPF_RGB = 0x40
|
52 |
+
DDPF_LUMINANCE = 0x20000
|
53 |
+
|
54 |
+
|
55 |
+
# dds.h
|
56 |
+
|
57 |
+
DDS_FOURCC = DDPF_FOURCC
|
58 |
+
DDS_RGB = DDPF_RGB
|
59 |
+
DDS_RGBA = DDPF_RGB | DDPF_ALPHAPIXELS
|
60 |
+
DDS_LUMINANCE = DDPF_LUMINANCE
|
61 |
+
DDS_LUMINANCEA = DDPF_LUMINANCE | DDPF_ALPHAPIXELS
|
62 |
+
DDS_ALPHA = DDPF_ALPHA
|
63 |
+
DDS_PAL8 = DDPF_PALETTEINDEXED8
|
64 |
+
|
65 |
+
DDS_HEADER_FLAGS_TEXTURE = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
|
66 |
+
DDS_HEADER_FLAGS_MIPMAP = DDSD_MIPMAPCOUNT
|
67 |
+
DDS_HEADER_FLAGS_VOLUME = DDSD_DEPTH
|
68 |
+
DDS_HEADER_FLAGS_PITCH = DDSD_PITCH
|
69 |
+
DDS_HEADER_FLAGS_LINEARSIZE = DDSD_LINEARSIZE
|
70 |
+
|
71 |
+
DDS_HEIGHT = DDSD_HEIGHT
|
72 |
+
DDS_WIDTH = DDSD_WIDTH
|
73 |
+
|
74 |
+
DDS_SURFACE_FLAGS_TEXTURE = DDSCAPS_TEXTURE
|
75 |
+
DDS_SURFACE_FLAGS_MIPMAP = DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
|
76 |
+
DDS_SURFACE_FLAGS_CUBEMAP = DDSCAPS_COMPLEX
|
77 |
+
|
78 |
+
DDS_CUBEMAP_POSITIVEX = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
79 |
+
DDS_CUBEMAP_NEGATIVEX = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
80 |
+
DDS_CUBEMAP_POSITIVEY = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
|
81 |
+
DDS_CUBEMAP_NEGATIVEY = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
|
82 |
+
DDS_CUBEMAP_POSITIVEZ = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
|
83 |
+
DDS_CUBEMAP_NEGATIVEZ = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
|
84 |
+
|
85 |
+
|
86 |
+
# DXT1
|
87 |
+
DXT1_FOURCC = 0x31545844
|
88 |
+
|
89 |
+
# DXT3
|
90 |
+
DXT3_FOURCC = 0x33545844
|
91 |
+
|
92 |
+
# DXT5
|
93 |
+
DXT5_FOURCC = 0x35545844
|
94 |
+
|
95 |
+
|
96 |
+
# dxgiformat.h
|
97 |
+
|
98 |
+
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27
|
99 |
+
DXGI_FORMAT_R8G8B8A8_UNORM = 28
|
100 |
+
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29
|
101 |
+
DXGI_FORMAT_BC5_TYPELESS = 82
|
102 |
+
DXGI_FORMAT_BC5_UNORM = 83
|
103 |
+
DXGI_FORMAT_BC5_SNORM = 84
|
104 |
+
DXGI_FORMAT_BC6H_UF16 = 95
|
105 |
+
DXGI_FORMAT_BC6H_SF16 = 96
|
106 |
+
DXGI_FORMAT_BC7_TYPELESS = 97
|
107 |
+
DXGI_FORMAT_BC7_UNORM = 98
|
108 |
+
DXGI_FORMAT_BC7_UNORM_SRGB = 99
|
109 |
+
|
110 |
+
|
111 |
+
class DdsImageFile(ImageFile.ImageFile):
|
112 |
+
format = "DDS"
|
113 |
+
format_description = "DirectDraw Surface"
|
114 |
+
|
115 |
+
def _open(self):
|
116 |
+
if not _accept(self.fp.read(4)):
|
117 |
+
msg = "not a DDS file"
|
118 |
+
raise SyntaxError(msg)
|
119 |
+
(header_size,) = struct.unpack("<I", self.fp.read(4))
|
120 |
+
if header_size != 124:
|
121 |
+
msg = f"Unsupported header size {repr(header_size)}"
|
122 |
+
raise OSError(msg)
|
123 |
+
header_bytes = self.fp.read(header_size - 4)
|
124 |
+
if len(header_bytes) != 120:
|
125 |
+
msg = f"Incomplete header: {len(header_bytes)} bytes"
|
126 |
+
raise OSError(msg)
|
127 |
+
header = BytesIO(header_bytes)
|
128 |
+
|
129 |
+
flags, height, width = struct.unpack("<3I", header.read(12))
|
130 |
+
self._size = (width, height)
|
131 |
+
self._mode = "RGBA"
|
132 |
+
|
133 |
+
pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
|
134 |
+
struct.unpack("<11I", header.read(44)) # reserved
|
135 |
+
|
136 |
+
# pixel format
|
137 |
+
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
138 |
+
fourcc = header.read(4)
|
139 |
+
(bitcount,) = struct.unpack("<I", header.read(4))
|
140 |
+
masks = struct.unpack("<4I", header.read(16))
|
141 |
+
if pfflags & DDPF_LUMINANCE:
|
142 |
+
# Texture contains uncompressed L or LA data
|
143 |
+
if pfflags & DDPF_ALPHAPIXELS:
|
144 |
+
self._mode = "LA"
|
145 |
+
else:
|
146 |
+
self._mode = "L"
|
147 |
+
|
148 |
+
self.tile = [("raw", (0, 0) + self.size, 0, (self.mode, 0, 1))]
|
149 |
+
elif pfflags & DDPF_RGB:
|
150 |
+
# Texture contains uncompressed RGB data
|
151 |
+
masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
|
152 |
+
rawmode = ""
|
153 |
+
if pfflags & DDPF_ALPHAPIXELS:
|
154 |
+
rawmode += masks[0xFF000000]
|
155 |
+
else:
|
156 |
+
self._mode = "RGB"
|
157 |
+
rawmode += masks[0xFF0000] + masks[0xFF00] + masks[0xFF]
|
158 |
+
|
159 |
+
self.tile = [("raw", (0, 0) + self.size, 0, (rawmode[::-1], 0, 1))]
|
160 |
+
elif pfflags & DDPF_PALETTEINDEXED8:
|
161 |
+
self._mode = "P"
|
162 |
+
self.palette = ImagePalette.raw("RGBA", self.fp.read(1024))
|
163 |
+
self.tile = [("raw", (0, 0) + self.size, 0, "L")]
|
164 |
+
else:
|
165 |
+
data_start = header_size + 4
|
166 |
+
n = 0
|
167 |
+
if fourcc == b"DXT1":
|
168 |
+
self.pixel_format = "DXT1"
|
169 |
+
n = 1
|
170 |
+
elif fourcc == b"DXT3":
|
171 |
+
self.pixel_format = "DXT3"
|
172 |
+
n = 2
|
173 |
+
elif fourcc == b"DXT5":
|
174 |
+
self.pixel_format = "DXT5"
|
175 |
+
n = 3
|
176 |
+
elif fourcc == b"ATI1":
|
177 |
+
self.pixel_format = "BC4"
|
178 |
+
n = 4
|
179 |
+
self._mode = "L"
|
180 |
+
elif fourcc in (b"ATI2", b"BC5U"):
|
181 |
+
self.pixel_format = "BC5"
|
182 |
+
n = 5
|
183 |
+
self._mode = "RGB"
|
184 |
+
elif fourcc == b"BC5S":
|
185 |
+
self.pixel_format = "BC5S"
|
186 |
+
n = 5
|
187 |
+
self._mode = "RGB"
|
188 |
+
elif fourcc == b"DX10":
|
189 |
+
data_start += 20
|
190 |
+
# ignoring flags which pertain to volume textures and cubemaps
|
191 |
+
(dxgi_format,) = struct.unpack("<I", self.fp.read(4))
|
192 |
+
self.fp.read(16)
|
193 |
+
if dxgi_format in (DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM):
|
194 |
+
self.pixel_format = "BC5"
|
195 |
+
n = 5
|
196 |
+
self._mode = "RGB"
|
197 |
+
elif dxgi_format == DXGI_FORMAT_BC5_SNORM:
|
198 |
+
self.pixel_format = "BC5S"
|
199 |
+
n = 5
|
200 |
+
self._mode = "RGB"
|
201 |
+
elif dxgi_format == DXGI_FORMAT_BC6H_UF16:
|
202 |
+
self.pixel_format = "BC6H"
|
203 |
+
n = 6
|
204 |
+
self._mode = "RGB"
|
205 |
+
elif dxgi_format == DXGI_FORMAT_BC6H_SF16:
|
206 |
+
self.pixel_format = "BC6HS"
|
207 |
+
n = 6
|
208 |
+
self._mode = "RGB"
|
209 |
+
elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM):
|
210 |
+
self.pixel_format = "BC7"
|
211 |
+
n = 7
|
212 |
+
elif dxgi_format == DXGI_FORMAT_BC7_UNORM_SRGB:
|
213 |
+
self.pixel_format = "BC7"
|
214 |
+
self.info["gamma"] = 1 / 2.2
|
215 |
+
n = 7
|
216 |
+
elif dxgi_format in (
|
217 |
+
DXGI_FORMAT_R8G8B8A8_TYPELESS,
|
218 |
+
DXGI_FORMAT_R8G8B8A8_UNORM,
|
219 |
+
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
|
220 |
+
):
|
221 |
+
self.tile = [("raw", (0, 0) + self.size, 0, ("RGBA", 0, 1))]
|
222 |
+
if dxgi_format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
223 |
+
self.info["gamma"] = 1 / 2.2
|
224 |
+
return
|
225 |
+
else:
|
226 |
+
msg = f"Unimplemented DXGI format {dxgi_format}"
|
227 |
+
raise NotImplementedError(msg)
|
228 |
+
else:
|
229 |
+
msg = f"Unimplemented pixel format {repr(fourcc)}"
|
230 |
+
raise NotImplementedError(msg)
|
231 |
+
|
232 |
+
self.tile = [
|
233 |
+
("bcn", (0, 0) + self.size, data_start, (n, self.pixel_format))
|
234 |
+
]
|
235 |
+
|
236 |
+
def load_seek(self, pos):
|
237 |
+
pass
|
238 |
+
|
239 |
+
|
240 |
+
def _save(im, fp, filename):
|
241 |
+
if im.mode not in ("RGB", "RGBA", "L", "LA"):
|
242 |
+
msg = f"cannot write mode {im.mode} as DDS"
|
243 |
+
raise OSError(msg)
|
244 |
+
|
245 |
+
rawmode = im.mode
|
246 |
+
masks = [0xFF0000, 0xFF00, 0xFF]
|
247 |
+
if im.mode in ("L", "LA"):
|
248 |
+
pixel_flags = DDPF_LUMINANCE
|
249 |
+
else:
|
250 |
+
pixel_flags = DDPF_RGB
|
251 |
+
rawmode = rawmode[::-1]
|
252 |
+
if im.mode in ("LA", "RGBA"):
|
253 |
+
pixel_flags |= DDPF_ALPHAPIXELS
|
254 |
+
masks.append(0xFF000000)
|
255 |
+
|
256 |
+
bitcount = len(masks) * 8
|
257 |
+
while len(masks) < 4:
|
258 |
+
masks.append(0)
|
259 |
+
|
260 |
+
fp.write(
|
261 |
+
o32(DDS_MAGIC)
|
262 |
+
+ o32(124) # header size
|
263 |
+
+ o32(
|
264 |
+
DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH | DDSD_PIXELFORMAT
|
265 |
+
) # flags
|
266 |
+
+ o32(im.height)
|
267 |
+
+ o32(im.width)
|
268 |
+
+ o32((im.width * bitcount + 7) // 8) # pitch
|
269 |
+
+ o32(0) # depth
|
270 |
+
+ o32(0) # mipmaps
|
271 |
+
+ o32(0) * 11 # reserved
|
272 |
+
+ o32(32) # pfsize
|
273 |
+
+ o32(pixel_flags) # pfflags
|
274 |
+
+ o32(0) # fourcc
|
275 |
+
+ o32(bitcount) # bitcount
|
276 |
+
+ b"".join(o32(mask) for mask in masks) # rgbabitmask
|
277 |
+
+ o32(DDSCAPS_TEXTURE) # dwCaps
|
278 |
+
+ o32(0) # dwCaps2
|
279 |
+
+ o32(0) # dwCaps3
|
280 |
+
+ o32(0) # dwCaps4
|
281 |
+
+ o32(0) # dwReserved2
|
282 |
+
)
|
283 |
+
if im.mode == "RGBA":
|
284 |
+
r, g, b, a = im.split()
|
285 |
+
im = Image.merge("RGBA", (a, r, g, b))
|
286 |
+
ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))])
|
287 |
+
|
288 |
+
|
289 |
+
def _accept(prefix):
|
290 |
+
return prefix[:4] == b"DDS "
|
291 |
+
|
292 |
+
|
293 |
+
Image.register_open(DdsImageFile.format, DdsImageFile, _accept)
|
294 |
+
Image.register_save(DdsImageFile.format, _save)
|
295 |
+
Image.register_extension(DdsImageFile.format, ".dds")
|
venv/Lib/site-packages/PIL/EpsImagePlugin.py
ADDED
@@ -0,0 +1,480 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# EPS file handling
|
6 |
+
#
|
7 |
+
# History:
|
8 |
+
# 1995-09-01 fl Created (0.1)
|
9 |
+
# 1996-05-18 fl Don't choke on "atend" fields, Ghostscript interface (0.2)
|
10 |
+
# 1996-08-22 fl Don't choke on floating point BoundingBox values
|
11 |
+
# 1996-08-23 fl Handle files from Macintosh (0.3)
|
12 |
+
# 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.4)
|
13 |
+
# 2003-09-07 fl Check gs.close status (from Federico Di Gregorio) (0.5)
|
14 |
+
# 2014-05-07 e Handling of EPS with binary preview and fixed resolution
|
15 |
+
# resizing
|
16 |
+
#
|
17 |
+
# Copyright (c) 1997-2003 by Secret Labs AB.
|
18 |
+
# Copyright (c) 1995-2003 by Fredrik Lundh
|
19 |
+
#
|
20 |
+
# See the README file for information on usage and redistribution.
|
21 |
+
#
|
22 |
+
|
23 |
+
import io
|
24 |
+
import os
|
25 |
+
import re
|
26 |
+
import subprocess
|
27 |
+
import sys
|
28 |
+
import tempfile
|
29 |
+
|
30 |
+
from . import Image, ImageFile
|
31 |
+
from ._binary import i32le as i32
|
32 |
+
from ._deprecate import deprecate
|
33 |
+
|
34 |
+
# --------------------------------------------------------------------
|
35 |
+
|
36 |
+
|
37 |
+
split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
|
38 |
+
field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
|
39 |
+
|
40 |
+
gs_binary = None
|
41 |
+
gs_windows_binary = None
|
42 |
+
|
43 |
+
|
44 |
+
def has_ghostscript():
|
45 |
+
global gs_binary, gs_windows_binary
|
46 |
+
if gs_binary is None:
|
47 |
+
if sys.platform.startswith("win"):
|
48 |
+
if gs_windows_binary is None:
|
49 |
+
import shutil
|
50 |
+
|
51 |
+
for binary in ("gswin32c", "gswin64c", "gs"):
|
52 |
+
if shutil.which(binary) is not None:
|
53 |
+
gs_windows_binary = binary
|
54 |
+
break
|
55 |
+
else:
|
56 |
+
gs_windows_binary = False
|
57 |
+
gs_binary = gs_windows_binary
|
58 |
+
else:
|
59 |
+
try:
|
60 |
+
subprocess.check_call(["gs", "--version"], stdout=subprocess.DEVNULL)
|
61 |
+
gs_binary = "gs"
|
62 |
+
except OSError:
|
63 |
+
gs_binary = False
|
64 |
+
return gs_binary is not False
|
65 |
+
|
66 |
+
|
67 |
+
def Ghostscript(tile, size, fp, scale=1, transparency=False):
|
68 |
+
"""Render an image using Ghostscript"""
|
69 |
+
global gs_binary
|
70 |
+
if not has_ghostscript():
|
71 |
+
msg = "Unable to locate Ghostscript on paths"
|
72 |
+
raise OSError(msg)
|
73 |
+
|
74 |
+
# Unpack decoder tile
|
75 |
+
decoder, tile, offset, data = tile[0]
|
76 |
+
length, bbox = data
|
77 |
+
|
78 |
+
# Hack to support hi-res rendering
|
79 |
+
scale = int(scale) or 1
|
80 |
+
# orig_size = size
|
81 |
+
# orig_bbox = bbox
|
82 |
+
size = (size[0] * scale, size[1] * scale)
|
83 |
+
# resolution is dependent on bbox and size
|
84 |
+
res = (
|
85 |
+
72.0 * size[0] / (bbox[2] - bbox[0]),
|
86 |
+
72.0 * size[1] / (bbox[3] - bbox[1]),
|
87 |
+
)
|
88 |
+
|
89 |
+
out_fd, outfile = tempfile.mkstemp()
|
90 |
+
os.close(out_fd)
|
91 |
+
|
92 |
+
infile_temp = None
|
93 |
+
if hasattr(fp, "name") and os.path.exists(fp.name):
|
94 |
+
infile = fp.name
|
95 |
+
else:
|
96 |
+
in_fd, infile_temp = tempfile.mkstemp()
|
97 |
+
os.close(in_fd)
|
98 |
+
infile = infile_temp
|
99 |
+
|
100 |
+
# Ignore length and offset!
|
101 |
+
# Ghostscript can read it
|
102 |
+
# Copy whole file to read in Ghostscript
|
103 |
+
with open(infile_temp, "wb") as f:
|
104 |
+
# fetch length of fp
|
105 |
+
fp.seek(0, io.SEEK_END)
|
106 |
+
fsize = fp.tell()
|
107 |
+
# ensure start position
|
108 |
+
# go back
|
109 |
+
fp.seek(0)
|
110 |
+
lengthfile = fsize
|
111 |
+
while lengthfile > 0:
|
112 |
+
s = fp.read(min(lengthfile, 100 * 1024))
|
113 |
+
if not s:
|
114 |
+
break
|
115 |
+
lengthfile -= len(s)
|
116 |
+
f.write(s)
|
117 |
+
|
118 |
+
device = "pngalpha" if transparency else "ppmraw"
|
119 |
+
|
120 |
+
# Build Ghostscript command
|
121 |
+
command = [
|
122 |
+
gs_binary,
|
123 |
+
"-q", # quiet mode
|
124 |
+
"-g%dx%d" % size, # set output geometry (pixels)
|
125 |
+
"-r%fx%f" % res, # set input DPI (dots per inch)
|
126 |
+
"-dBATCH", # exit after processing
|
127 |
+
"-dNOPAUSE", # don't pause between pages
|
128 |
+
"-dSAFER", # safe mode
|
129 |
+
f"-sDEVICE={device}",
|
130 |
+
f"-sOutputFile={outfile}", # output file
|
131 |
+
# adjust for image origin
|
132 |
+
"-c",
|
133 |
+
f"{-bbox[0]} {-bbox[1]} translate",
|
134 |
+
"-f",
|
135 |
+
infile, # input file
|
136 |
+
# showpage (see https://bugs.ghostscript.com/show_bug.cgi?id=698272)
|
137 |
+
"-c",
|
138 |
+
"showpage",
|
139 |
+
]
|
140 |
+
|
141 |
+
# push data through Ghostscript
|
142 |
+
try:
|
143 |
+
startupinfo = None
|
144 |
+
if sys.platform.startswith("win"):
|
145 |
+
startupinfo = subprocess.STARTUPINFO()
|
146 |
+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
147 |
+
subprocess.check_call(command, startupinfo=startupinfo)
|
148 |
+
out_im = Image.open(outfile)
|
149 |
+
out_im.load()
|
150 |
+
finally:
|
151 |
+
try:
|
152 |
+
os.unlink(outfile)
|
153 |
+
if infile_temp:
|
154 |
+
os.unlink(infile_temp)
|
155 |
+
except OSError:
|
156 |
+
pass
|
157 |
+
|
158 |
+
im = out_im.im.copy()
|
159 |
+
out_im.close()
|
160 |
+
return im
|
161 |
+
|
162 |
+
|
163 |
+
class PSFile:
|
164 |
+
"""
|
165 |
+
Wrapper for bytesio object that treats either CR or LF as end of line.
|
166 |
+
This class is no longer used internally, but kept for backwards compatibility.
|
167 |
+
"""
|
168 |
+
|
169 |
+
def __init__(self, fp):
|
170 |
+
deprecate(
|
171 |
+
"PSFile",
|
172 |
+
11,
|
173 |
+
action="If you need the functionality of this class "
|
174 |
+
"you will need to implement it yourself.",
|
175 |
+
)
|
176 |
+
self.fp = fp
|
177 |
+
self.char = None
|
178 |
+
|
179 |
+
def seek(self, offset, whence=io.SEEK_SET):
|
180 |
+
self.char = None
|
181 |
+
self.fp.seek(offset, whence)
|
182 |
+
|
183 |
+
def readline(self):
|
184 |
+
s = [self.char or b""]
|
185 |
+
self.char = None
|
186 |
+
|
187 |
+
c = self.fp.read(1)
|
188 |
+
while (c not in b"\r\n") and len(c):
|
189 |
+
s.append(c)
|
190 |
+
c = self.fp.read(1)
|
191 |
+
|
192 |
+
self.char = self.fp.read(1)
|
193 |
+
# line endings can be 1 or 2 of \r \n, in either order
|
194 |
+
if self.char in b"\r\n":
|
195 |
+
self.char = None
|
196 |
+
|
197 |
+
return b"".join(s).decode("latin-1")
|
198 |
+
|
199 |
+
|
200 |
+
def _accept(prefix):
|
201 |
+
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
202 |
+
|
203 |
+
|
204 |
+
##
|
205 |
+
# Image plugin for Encapsulated PostScript. This plugin supports only
|
206 |
+
# a few variants of this format.
|
207 |
+
|
208 |
+
|
209 |
+
class EpsImageFile(ImageFile.ImageFile):
|
210 |
+
"""EPS File Parser for the Python Imaging Library"""
|
211 |
+
|
212 |
+
format = "EPS"
|
213 |
+
format_description = "Encapsulated Postscript"
|
214 |
+
|
215 |
+
mode_map = {1: "L", 2: "LAB", 3: "RGB", 4: "CMYK"}
|
216 |
+
|
217 |
+
def _open(self):
|
218 |
+
(length, offset) = self._find_offset(self.fp)
|
219 |
+
|
220 |
+
# go to offset - start of "%!PS"
|
221 |
+
self.fp.seek(offset)
|
222 |
+
|
223 |
+
self._mode = "RGB"
|
224 |
+
self._size = None
|
225 |
+
|
226 |
+
byte_arr = bytearray(255)
|
227 |
+
bytes_mv = memoryview(byte_arr)
|
228 |
+
bytes_read = 0
|
229 |
+
reading_header_comments = True
|
230 |
+
reading_trailer_comments = False
|
231 |
+
trailer_reached = False
|
232 |
+
|
233 |
+
def check_required_header_comments():
|
234 |
+
if "PS-Adobe" not in self.info:
|
235 |
+
msg = 'EPS header missing "%!PS-Adobe" comment'
|
236 |
+
raise SyntaxError(msg)
|
237 |
+
if "BoundingBox" not in self.info:
|
238 |
+
msg = 'EPS header missing "%%BoundingBox" comment'
|
239 |
+
raise SyntaxError(msg)
|
240 |
+
|
241 |
+
def _read_comment(s):
|
242 |
+
nonlocal reading_trailer_comments
|
243 |
+
try:
|
244 |
+
m = split.match(s)
|
245 |
+
except re.error as e:
|
246 |
+
msg = "not an EPS file"
|
247 |
+
raise SyntaxError(msg) from e
|
248 |
+
|
249 |
+
if m:
|
250 |
+
k, v = m.group(1, 2)
|
251 |
+
self.info[k] = v
|
252 |
+
if k == "BoundingBox":
|
253 |
+
if v == "(atend)":
|
254 |
+
reading_trailer_comments = True
|
255 |
+
elif not self._size or (
|
256 |
+
trailer_reached and reading_trailer_comments
|
257 |
+
):
|
258 |
+
try:
|
259 |
+
# Note: The DSC spec says that BoundingBox
|
260 |
+
# fields should be integers, but some drivers
|
261 |
+
# put floating point values there anyway.
|
262 |
+
box = [int(float(i)) for i in v.split()]
|
263 |
+
self._size = box[2] - box[0], box[3] - box[1]
|
264 |
+
self.tile = [
|
265 |
+
("eps", (0, 0) + self.size, offset, (length, box))
|
266 |
+
]
|
267 |
+
except Exception:
|
268 |
+
pass
|
269 |
+
return True
|
270 |
+
|
271 |
+
while True:
|
272 |
+
byte = self.fp.read(1)
|
273 |
+
if byte == b"":
|
274 |
+
# if we didn't read a byte we must be at the end of the file
|
275 |
+
if bytes_read == 0:
|
276 |
+
break
|
277 |
+
elif byte in b"\r\n":
|
278 |
+
# if we read a line ending character, ignore it and parse what
|
279 |
+
# we have already read. if we haven't read any other characters,
|
280 |
+
# continue reading
|
281 |
+
if bytes_read == 0:
|
282 |
+
continue
|
283 |
+
else:
|
284 |
+
# ASCII/hexadecimal lines in an EPS file must not exceed
|
285 |
+
# 255 characters, not including line ending characters
|
286 |
+
if bytes_read >= 255:
|
287 |
+
# only enforce this for lines starting with a "%",
|
288 |
+
# otherwise assume it's binary data
|
289 |
+
if byte_arr[0] == ord("%"):
|
290 |
+
msg = "not an EPS file"
|
291 |
+
raise SyntaxError(msg)
|
292 |
+
else:
|
293 |
+
if reading_header_comments:
|
294 |
+
check_required_header_comments()
|
295 |
+
reading_header_comments = False
|
296 |
+
# reset bytes_read so we can keep reading
|
297 |
+
# data until the end of the line
|
298 |
+
bytes_read = 0
|
299 |
+
byte_arr[bytes_read] = byte[0]
|
300 |
+
bytes_read += 1
|
301 |
+
continue
|
302 |
+
|
303 |
+
if reading_header_comments:
|
304 |
+
# Load EPS header
|
305 |
+
|
306 |
+
# if this line doesn't start with a "%",
|
307 |
+
# or does start with "%%EndComments",
|
308 |
+
# then we've reached the end of the header/comments
|
309 |
+
if byte_arr[0] != ord("%") or bytes_mv[:13] == b"%%EndComments":
|
310 |
+
check_required_header_comments()
|
311 |
+
reading_header_comments = False
|
312 |
+
continue
|
313 |
+
|
314 |
+
s = str(bytes_mv[:bytes_read], "latin-1")
|
315 |
+
if not _read_comment(s):
|
316 |
+
m = field.match(s)
|
317 |
+
if m:
|
318 |
+
k = m.group(1)
|
319 |
+
if k[:8] == "PS-Adobe":
|
320 |
+
self.info["PS-Adobe"] = k[9:]
|
321 |
+
else:
|
322 |
+
self.info[k] = ""
|
323 |
+
elif s[0] == "%":
|
324 |
+
# handle non-DSC PostScript comments that some
|
325 |
+
# tools mistakenly put in the Comments section
|
326 |
+
pass
|
327 |
+
else:
|
328 |
+
msg = "bad EPS header"
|
329 |
+
raise OSError(msg)
|
330 |
+
elif bytes_mv[:11] == b"%ImageData:":
|
331 |
+
# Check for an "ImageData" descriptor
|
332 |
+
# https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096
|
333 |
+
|
334 |
+
# Values:
|
335 |
+
# columns
|
336 |
+
# rows
|
337 |
+
# bit depth (1 or 8)
|
338 |
+
# mode (1: L, 2: LAB, 3: RGB, 4: CMYK)
|
339 |
+
# number of padding channels
|
340 |
+
# block size (number of bytes per row per channel)
|
341 |
+
# binary/ascii (1: binary, 2: ascii)
|
342 |
+
# data start identifier (the image data follows after a single line
|
343 |
+
# consisting only of this quoted value)
|
344 |
+
image_data_values = byte_arr[11:bytes_read].split(None, 7)
|
345 |
+
columns, rows, bit_depth, mode_id = (
|
346 |
+
int(value) for value in image_data_values[:4]
|
347 |
+
)
|
348 |
+
|
349 |
+
if bit_depth == 1:
|
350 |
+
self._mode = "1"
|
351 |
+
elif bit_depth == 8:
|
352 |
+
try:
|
353 |
+
self._mode = self.mode_map[mode_id]
|
354 |
+
except ValueError:
|
355 |
+
break
|
356 |
+
else:
|
357 |
+
break
|
358 |
+
|
359 |
+
self._size = columns, rows
|
360 |
+
return
|
361 |
+
elif trailer_reached and reading_trailer_comments:
|
362 |
+
# Load EPS trailer
|
363 |
+
|
364 |
+
# if this line starts with "%%EOF",
|
365 |
+
# then we've reached the end of the file
|
366 |
+
if bytes_mv[:5] == b"%%EOF":
|
367 |
+
break
|
368 |
+
|
369 |
+
s = str(bytes_mv[:bytes_read], "latin-1")
|
370 |
+
_read_comment(s)
|
371 |
+
elif bytes_mv[:9] == b"%%Trailer":
|
372 |
+
trailer_reached = True
|
373 |
+
bytes_read = 0
|
374 |
+
|
375 |
+
check_required_header_comments()
|
376 |
+
|
377 |
+
if not self._size:
|
378 |
+
msg = "cannot determine EPS bounding box"
|
379 |
+
raise OSError(msg)
|
380 |
+
|
381 |
+
def _find_offset(self, fp):
|
382 |
+
s = fp.read(4)
|
383 |
+
|
384 |
+
if s == b"%!PS":
|
385 |
+
# for HEAD without binary preview
|
386 |
+
fp.seek(0, io.SEEK_END)
|
387 |
+
length = fp.tell()
|
388 |
+
offset = 0
|
389 |
+
elif i32(s) == 0xC6D3D0C5:
|
390 |
+
# FIX for: Some EPS file not handled correctly / issue #302
|
391 |
+
# EPS can contain binary data
|
392 |
+
# or start directly with latin coding
|
393 |
+
# more info see:
|
394 |
+
# https://web.archive.org/web/20160528181353/http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf
|
395 |
+
s = fp.read(8)
|
396 |
+
offset = i32(s)
|
397 |
+
length = i32(s, 4)
|
398 |
+
else:
|
399 |
+
msg = "not an EPS file"
|
400 |
+
raise SyntaxError(msg)
|
401 |
+
|
402 |
+
return length, offset
|
403 |
+
|
404 |
+
def load(self, scale=1, transparency=False):
|
405 |
+
# Load EPS via Ghostscript
|
406 |
+
if self.tile:
|
407 |
+
self.im = Ghostscript(self.tile, self.size, self.fp, scale, transparency)
|
408 |
+
self._mode = self.im.mode
|
409 |
+
self._size = self.im.size
|
410 |
+
self.tile = []
|
411 |
+
return Image.Image.load(self)
|
412 |
+
|
413 |
+
def load_seek(self, *args, **kwargs):
|
414 |
+
# we can't incrementally load, so force ImageFile.parser to
|
415 |
+
# use our custom load method by defining this method.
|
416 |
+
pass
|
417 |
+
|
418 |
+
|
419 |
+
# --------------------------------------------------------------------
|
420 |
+
|
421 |
+
|
422 |
+
def _save(im, fp, filename, eps=1):
|
423 |
+
"""EPS Writer for the Python Imaging Library."""
|
424 |
+
|
425 |
+
# make sure image data is available
|
426 |
+
im.load()
|
427 |
+
|
428 |
+
# determine PostScript image mode
|
429 |
+
if im.mode == "L":
|
430 |
+
operator = (8, 1, b"image")
|
431 |
+
elif im.mode == "RGB":
|
432 |
+
operator = (8, 3, b"false 3 colorimage")
|
433 |
+
elif im.mode == "CMYK":
|
434 |
+
operator = (8, 4, b"false 4 colorimage")
|
435 |
+
else:
|
436 |
+
msg = "image mode is not supported"
|
437 |
+
raise ValueError(msg)
|
438 |
+
|
439 |
+
if eps:
|
440 |
+
# write EPS header
|
441 |
+
fp.write(b"%!PS-Adobe-3.0 EPSF-3.0\n")
|
442 |
+
fp.write(b"%%Creator: PIL 0.1 EpsEncode\n")
|
443 |
+
# fp.write("%%CreationDate: %s"...)
|
444 |
+
fp.write(b"%%%%BoundingBox: 0 0 %d %d\n" % im.size)
|
445 |
+
fp.write(b"%%Pages: 1\n")
|
446 |
+
fp.write(b"%%EndComments\n")
|
447 |
+
fp.write(b"%%Page: 1 1\n")
|
448 |
+
fp.write(b"%%ImageData: %d %d " % im.size)
|
449 |
+
fp.write(b'%d %d 0 1 1 "%s"\n' % operator)
|
450 |
+
|
451 |
+
# image header
|
452 |
+
fp.write(b"gsave\n")
|
453 |
+
fp.write(b"10 dict begin\n")
|
454 |
+
fp.write(b"/buf %d string def\n" % (im.size[0] * operator[1]))
|
455 |
+
fp.write(b"%d %d scale\n" % im.size)
|
456 |
+
fp.write(b"%d %d 8\n" % im.size) # <= bits
|
457 |
+
fp.write(b"[%d 0 0 -%d 0 %d]\n" % (im.size[0], im.size[1], im.size[1]))
|
458 |
+
fp.write(b"{ currentfile buf readhexstring pop } bind\n")
|
459 |
+
fp.write(operator[2] + b"\n")
|
460 |
+
if hasattr(fp, "flush"):
|
461 |
+
fp.flush()
|
462 |
+
|
463 |
+
ImageFile._save(im, fp, [("eps", (0, 0) + im.size, 0, None)])
|
464 |
+
|
465 |
+
fp.write(b"\n%%%%EndBinary\n")
|
466 |
+
fp.write(b"grestore end\n")
|
467 |
+
if hasattr(fp, "flush"):
|
468 |
+
fp.flush()
|
469 |
+
|
470 |
+
|
471 |
+
# --------------------------------------------------------------------
|
472 |
+
|
473 |
+
|
474 |
+
Image.register_open(EpsImageFile.format, EpsImageFile, _accept)
|
475 |
+
|
476 |
+
Image.register_save(EpsImageFile.format, _save)
|
477 |
+
|
478 |
+
Image.register_extensions(EpsImageFile.format, [".ps", ".eps"])
|
479 |
+
|
480 |
+
Image.register_mime(EpsImageFile.format, "application/postscript")
|
venv/Lib/site-packages/PIL/ExifTags.py
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 enum import IntEnum
|
18 |
+
|
19 |
+
|
20 |
+
class Base(IntEnum):
|
21 |
+
# possibly incomplete
|
22 |
+
InteropIndex = 0x0001
|
23 |
+
ProcessingSoftware = 0x000B
|
24 |
+
NewSubfileType = 0x00FE
|
25 |
+
SubfileType = 0x00FF
|
26 |
+
ImageWidth = 0x0100
|
27 |
+
ImageLength = 0x0101
|
28 |
+
BitsPerSample = 0x0102
|
29 |
+
Compression = 0x0103
|
30 |
+
PhotometricInterpretation = 0x0106
|
31 |
+
Thresholding = 0x0107
|
32 |
+
CellWidth = 0x0108
|
33 |
+
CellLength = 0x0109
|
34 |
+
FillOrder = 0x010A
|
35 |
+
DocumentName = 0x010D
|
36 |
+
ImageDescription = 0x010E
|
37 |
+
Make = 0x010F
|
38 |
+
Model = 0x0110
|
39 |
+
StripOffsets = 0x0111
|
40 |
+
Orientation = 0x0112
|
41 |
+
SamplesPerPixel = 0x0115
|
42 |
+
RowsPerStrip = 0x0116
|
43 |
+
StripByteCounts = 0x0117
|
44 |
+
MinSampleValue = 0x0118
|
45 |
+
MaxSampleValue = 0x0119
|
46 |
+
XResolution = 0x011A
|
47 |
+
YResolution = 0x011B
|
48 |
+
PlanarConfiguration = 0x011C
|
49 |
+
PageName = 0x011D
|
50 |
+
FreeOffsets = 0x0120
|
51 |
+
FreeByteCounts = 0x0121
|
52 |
+
GrayResponseUnit = 0x0122
|
53 |
+
GrayResponseCurve = 0x0123
|
54 |
+
T4Options = 0x0124
|
55 |
+
T6Options = 0x0125
|
56 |
+
ResolutionUnit = 0x0128
|
57 |
+
PageNumber = 0x0129
|
58 |
+
TransferFunction = 0x012D
|
59 |
+
Software = 0x0131
|
60 |
+
DateTime = 0x0132
|
61 |
+
Artist = 0x013B
|
62 |
+
HostComputer = 0x013C
|
63 |
+
Predictor = 0x013D
|
64 |
+
WhitePoint = 0x013E
|
65 |
+
PrimaryChromaticities = 0x013F
|
66 |
+
ColorMap = 0x0140
|
67 |
+
HalftoneHints = 0x0141
|
68 |
+
TileWidth = 0x0142
|
69 |
+
TileLength = 0x0143
|
70 |
+
TileOffsets = 0x0144
|
71 |
+
TileByteCounts = 0x0145
|
72 |
+
SubIFDs = 0x014A
|
73 |
+
InkSet = 0x014C
|
74 |
+
InkNames = 0x014D
|
75 |
+
NumberOfInks = 0x014E
|
76 |
+
DotRange = 0x0150
|
77 |
+
TargetPrinter = 0x0151
|
78 |
+
ExtraSamples = 0x0152
|
79 |
+
SampleFormat = 0x0153
|
80 |
+
SMinSampleValue = 0x0154
|
81 |
+
SMaxSampleValue = 0x0155
|
82 |
+
TransferRange = 0x0156
|
83 |
+
ClipPath = 0x0157
|
84 |
+
XClipPathUnits = 0x0158
|
85 |
+
YClipPathUnits = 0x0159
|
86 |
+
Indexed = 0x015A
|
87 |
+
JPEGTables = 0x015B
|
88 |
+
OPIProxy = 0x015F
|
89 |
+
JPEGProc = 0x0200
|
90 |
+
JpegIFOffset = 0x0201
|
91 |
+
JpegIFByteCount = 0x0202
|
92 |
+
JpegRestartInterval = 0x0203
|
93 |
+
JpegLosslessPredictors = 0x0205
|
94 |
+
JpegPointTransforms = 0x0206
|
95 |
+
JpegQTables = 0x0207
|
96 |
+
JpegDCTables = 0x0208
|
97 |
+
JpegACTables = 0x0209
|
98 |
+
YCbCrCoefficients = 0x0211
|
99 |
+
YCbCrSubSampling = 0x0212
|
100 |
+
YCbCrPositioning = 0x0213
|
101 |
+
ReferenceBlackWhite = 0x0214
|
102 |
+
XMLPacket = 0x02BC
|
103 |
+
RelatedImageFileFormat = 0x1000
|
104 |
+
RelatedImageWidth = 0x1001
|
105 |
+
RelatedImageLength = 0x1002
|
106 |
+
Rating = 0x4746
|
107 |
+
RatingPercent = 0x4749
|
108 |
+
ImageID = 0x800D
|
109 |
+
CFARepeatPatternDim = 0x828D
|
110 |
+
BatteryLevel = 0x828F
|
111 |
+
Copyright = 0x8298
|
112 |
+
ExposureTime = 0x829A
|
113 |
+
FNumber = 0x829D
|
114 |
+
IPTCNAA = 0x83BB
|
115 |
+
ImageResources = 0x8649
|
116 |
+
ExifOffset = 0x8769
|
117 |
+
InterColorProfile = 0x8773
|
118 |
+
ExposureProgram = 0x8822
|
119 |
+
SpectralSensitivity = 0x8824
|
120 |
+
GPSInfo = 0x8825
|
121 |
+
ISOSpeedRatings = 0x8827
|
122 |
+
OECF = 0x8828
|
123 |
+
Interlace = 0x8829
|
124 |
+
TimeZoneOffset = 0x882A
|
125 |
+
SelfTimerMode = 0x882B
|
126 |
+
SensitivityType = 0x8830
|
127 |
+
StandardOutputSensitivity = 0x8831
|
128 |
+
RecommendedExposureIndex = 0x8832
|
129 |
+
ISOSpeed = 0x8833
|
130 |
+
ISOSpeedLatitudeyyy = 0x8834
|
131 |
+
ISOSpeedLatitudezzz = 0x8835
|
132 |
+
ExifVersion = 0x9000
|
133 |
+
DateTimeOriginal = 0x9003
|
134 |
+
DateTimeDigitized = 0x9004
|
135 |
+
OffsetTime = 0x9010
|
136 |
+
OffsetTimeOriginal = 0x9011
|
137 |
+
OffsetTimeDigitized = 0x9012
|
138 |
+
ComponentsConfiguration = 0x9101
|
139 |
+
CompressedBitsPerPixel = 0x9102
|
140 |
+
ShutterSpeedValue = 0x9201
|
141 |
+
ApertureValue = 0x9202
|
142 |
+
BrightnessValue = 0x9203
|
143 |
+
ExposureBiasValue = 0x9204
|
144 |
+
MaxApertureValue = 0x9205
|
145 |
+
SubjectDistance = 0x9206
|
146 |
+
MeteringMode = 0x9207
|
147 |
+
LightSource = 0x9208
|
148 |
+
Flash = 0x9209
|
149 |
+
FocalLength = 0x920A
|
150 |
+
Noise = 0x920D
|
151 |
+
ImageNumber = 0x9211
|
152 |
+
SecurityClassification = 0x9212
|
153 |
+
ImageHistory = 0x9213
|
154 |
+
TIFFEPStandardID = 0x9216
|
155 |
+
MakerNote = 0x927C
|
156 |
+
UserComment = 0x9286
|
157 |
+
SubsecTime = 0x9290
|
158 |
+
SubsecTimeOriginal = 0x9291
|
159 |
+
SubsecTimeDigitized = 0x9292
|
160 |
+
AmbientTemperature = 0x9400
|
161 |
+
Humidity = 0x9401
|
162 |
+
Pressure = 0x9402
|
163 |
+
WaterDepth = 0x9403
|
164 |
+
Acceleration = 0x9404
|
165 |
+
CameraElevationAngle = 0x9405
|
166 |
+
XPTitle = 0x9C9B
|
167 |
+
XPComment = 0x9C9C
|
168 |
+
XPAuthor = 0x9C9D
|
169 |
+
XPKeywords = 0x9C9E
|
170 |
+
XPSubject = 0x9C9F
|
171 |
+
FlashPixVersion = 0xA000
|
172 |
+
ColorSpace = 0xA001
|
173 |
+
ExifImageWidth = 0xA002
|
174 |
+
ExifImageHeight = 0xA003
|
175 |
+
RelatedSoundFile = 0xA004
|
176 |
+
ExifInteroperabilityOffset = 0xA005
|
177 |
+
FlashEnergy = 0xA20B
|
178 |
+
SpatialFrequencyResponse = 0xA20C
|
179 |
+
FocalPlaneXResolution = 0xA20E
|
180 |
+
FocalPlaneYResolution = 0xA20F
|
181 |
+
FocalPlaneResolutionUnit = 0xA210
|
182 |
+
SubjectLocation = 0xA214
|
183 |
+
ExposureIndex = 0xA215
|
184 |
+
SensingMethod = 0xA217
|
185 |
+
FileSource = 0xA300
|
186 |
+
SceneType = 0xA301
|
187 |
+
CFAPattern = 0xA302
|
188 |
+
CustomRendered = 0xA401
|
189 |
+
ExposureMode = 0xA402
|
190 |
+
WhiteBalance = 0xA403
|
191 |
+
DigitalZoomRatio = 0xA404
|
192 |
+
FocalLengthIn35mmFilm = 0xA405
|
193 |
+
SceneCaptureType = 0xA406
|
194 |
+
GainControl = 0xA407
|
195 |
+
Contrast = 0xA408
|
196 |
+
Saturation = 0xA409
|
197 |
+
Sharpness = 0xA40A
|
198 |
+
DeviceSettingDescription = 0xA40B
|
199 |
+
SubjectDistanceRange = 0xA40C
|
200 |
+
ImageUniqueID = 0xA420
|
201 |
+
CameraOwnerName = 0xA430
|
202 |
+
BodySerialNumber = 0xA431
|
203 |
+
LensSpecification = 0xA432
|
204 |
+
LensMake = 0xA433
|
205 |
+
LensModel = 0xA434
|
206 |
+
LensSerialNumber = 0xA435
|
207 |
+
CompositeImage = 0xA460
|
208 |
+
CompositeImageCount = 0xA461
|
209 |
+
CompositeImageExposureTimes = 0xA462
|
210 |
+
Gamma = 0xA500
|
211 |
+
PrintImageMatching = 0xC4A5
|
212 |
+
DNGVersion = 0xC612
|
213 |
+
DNGBackwardVersion = 0xC613
|
214 |
+
UniqueCameraModel = 0xC614
|
215 |
+
LocalizedCameraModel = 0xC615
|
216 |
+
CFAPlaneColor = 0xC616
|
217 |
+
CFALayout = 0xC617
|
218 |
+
LinearizationTable = 0xC618
|
219 |
+
BlackLevelRepeatDim = 0xC619
|
220 |
+
BlackLevel = 0xC61A
|
221 |
+
BlackLevelDeltaH = 0xC61B
|
222 |
+
BlackLevelDeltaV = 0xC61C
|
223 |
+
WhiteLevel = 0xC61D
|
224 |
+
DefaultScale = 0xC61E
|
225 |
+
DefaultCropOrigin = 0xC61F
|
226 |
+
DefaultCropSize = 0xC620
|
227 |
+
ColorMatrix1 = 0xC621
|
228 |
+
ColorMatrix2 = 0xC622
|
229 |
+
CameraCalibration1 = 0xC623
|
230 |
+
CameraCalibration2 = 0xC624
|
231 |
+
ReductionMatrix1 = 0xC625
|
232 |
+
ReductionMatrix2 = 0xC626
|
233 |
+
AnalogBalance = 0xC627
|
234 |
+
AsShotNeutral = 0xC628
|
235 |
+
AsShotWhiteXY = 0xC629
|
236 |
+
BaselineExposure = 0xC62A
|
237 |
+
BaselineNoise = 0xC62B
|
238 |
+
BaselineSharpness = 0xC62C
|
239 |
+
BayerGreenSplit = 0xC62D
|
240 |
+
LinearResponseLimit = 0xC62E
|
241 |
+
CameraSerialNumber = 0xC62F
|
242 |
+
LensInfo = 0xC630
|
243 |
+
ChromaBlurRadius = 0xC631
|
244 |
+
AntiAliasStrength = 0xC632
|
245 |
+
ShadowScale = 0xC633
|
246 |
+
DNGPrivateData = 0xC634
|
247 |
+
MakerNoteSafety = 0xC635
|
248 |
+
CalibrationIlluminant1 = 0xC65A
|
249 |
+
CalibrationIlluminant2 = 0xC65B
|
250 |
+
BestQualityScale = 0xC65C
|
251 |
+
RawDataUniqueID = 0xC65D
|
252 |
+
OriginalRawFileName = 0xC68B
|
253 |
+
OriginalRawFileData = 0xC68C
|
254 |
+
ActiveArea = 0xC68D
|
255 |
+
MaskedAreas = 0xC68E
|
256 |
+
AsShotICCProfile = 0xC68F
|
257 |
+
AsShotPreProfileMatrix = 0xC690
|
258 |
+
CurrentICCProfile = 0xC691
|
259 |
+
CurrentPreProfileMatrix = 0xC692
|
260 |
+
ColorimetricReference = 0xC6BF
|
261 |
+
CameraCalibrationSignature = 0xC6F3
|
262 |
+
ProfileCalibrationSignature = 0xC6F4
|
263 |
+
AsShotProfileName = 0xC6F6
|
264 |
+
NoiseReductionApplied = 0xC6F7
|
265 |
+
ProfileName = 0xC6F8
|
266 |
+
ProfileHueSatMapDims = 0xC6F9
|
267 |
+
ProfileHueSatMapData1 = 0xC6FA
|
268 |
+
ProfileHueSatMapData2 = 0xC6FB
|
269 |
+
ProfileToneCurve = 0xC6FC
|
270 |
+
ProfileEmbedPolicy = 0xC6FD
|
271 |
+
ProfileCopyright = 0xC6FE
|
272 |
+
ForwardMatrix1 = 0xC714
|
273 |
+
ForwardMatrix2 = 0xC715
|
274 |
+
PreviewApplicationName = 0xC716
|
275 |
+
PreviewApplicationVersion = 0xC717
|
276 |
+
PreviewSettingsName = 0xC718
|
277 |
+
PreviewSettingsDigest = 0xC719
|
278 |
+
PreviewColorSpace = 0xC71A
|
279 |
+
PreviewDateTime = 0xC71B
|
280 |
+
RawImageDigest = 0xC71C
|
281 |
+
OriginalRawFileDigest = 0xC71D
|
282 |
+
SubTileBlockSize = 0xC71E
|
283 |
+
RowInterleaveFactor = 0xC71F
|
284 |
+
ProfileLookTableDims = 0xC725
|
285 |
+
ProfileLookTableData = 0xC726
|
286 |
+
OpcodeList1 = 0xC740
|
287 |
+
OpcodeList2 = 0xC741
|
288 |
+
OpcodeList3 = 0xC74E
|
289 |
+
NoiseProfile = 0xC761
|
290 |
+
|
291 |
+
|
292 |
+
"""Maps EXIF tags to tag names."""
|
293 |
+
TAGS = {
|
294 |
+
**{i.value: i.name for i in Base},
|
295 |
+
0x920C: "SpatialFrequencyResponse",
|
296 |
+
0x9214: "SubjectLocation",
|
297 |
+
0x9215: "ExposureIndex",
|
298 |
+
0x828E: "CFAPattern",
|
299 |
+
0x920B: "FlashEnergy",
|
300 |
+
0x9216: "TIFF/EPStandardID",
|
301 |
+
}
|
302 |
+
|
303 |
+
|
304 |
+
class GPS(IntEnum):
|
305 |
+
GPSVersionID = 0
|
306 |
+
GPSLatitudeRef = 1
|
307 |
+
GPSLatitude = 2
|
308 |
+
GPSLongitudeRef = 3
|
309 |
+
GPSLongitude = 4
|
310 |
+
GPSAltitudeRef = 5
|
311 |
+
GPSAltitude = 6
|
312 |
+
GPSTimeStamp = 7
|
313 |
+
GPSSatellites = 8
|
314 |
+
GPSStatus = 9
|
315 |
+
GPSMeasureMode = 10
|
316 |
+
GPSDOP = 11
|
317 |
+
GPSSpeedRef = 12
|
318 |
+
GPSSpeed = 13
|
319 |
+
GPSTrackRef = 14
|
320 |
+
GPSTrack = 15
|
321 |
+
GPSImgDirectionRef = 16
|
322 |
+
GPSImgDirection = 17
|
323 |
+
GPSMapDatum = 18
|
324 |
+
GPSDestLatitudeRef = 19
|
325 |
+
GPSDestLatitude = 20
|
326 |
+
GPSDestLongitudeRef = 21
|
327 |
+
GPSDestLongitude = 22
|
328 |
+
GPSDestBearingRef = 23
|
329 |
+
GPSDestBearing = 24
|
330 |
+
GPSDestDistanceRef = 25
|
331 |
+
GPSDestDistance = 26
|
332 |
+
GPSProcessingMethod = 27
|
333 |
+
GPSAreaInformation = 28
|
334 |
+
GPSDateStamp = 29
|
335 |
+
GPSDifferential = 30
|
336 |
+
GPSHPositioningError = 31
|
337 |
+
|
338 |
+
|
339 |
+
"""Maps EXIF GPS tags to tag names."""
|
340 |
+
GPSTAGS = {i.value: i.name for i in GPS}
|
341 |
+
|
342 |
+
|
343 |
+
class Interop(IntEnum):
|
344 |
+
InteropIndex = 1
|
345 |
+
InteropVersion = 2
|
346 |
+
RelatedImageFileFormat = 4096
|
347 |
+
RelatedImageWidth = 4097
|
348 |
+
RleatedImageHeight = 4098
|
349 |
+
|
350 |
+
|
351 |
+
class IFD(IntEnum):
|
352 |
+
Exif = 34665
|
353 |
+
GPSInfo = 34853
|
354 |
+
Makernote = 37500
|
355 |
+
Interop = 40965
|
356 |
+
IFD1 = -1
|
357 |
+
|
358 |
+
|
359 |
+
class LightSource(IntEnum):
|
360 |
+
Unknown = 0
|
361 |
+
Daylight = 1
|
362 |
+
Fluorescent = 2
|
363 |
+
Tungsten = 3
|
364 |
+
Flash = 4
|
365 |
+
Fine = 9
|
366 |
+
Cloudy = 10
|
367 |
+
Shade = 11
|
368 |
+
DaylightFluorescent = 12
|
369 |
+
DayWhiteFluorescent = 13
|
370 |
+
CoolWhiteFluorescent = 14
|
371 |
+
WhiteFluorescent = 15
|
372 |
+
StandardLightA = 17
|
373 |
+
StandardLightB = 18
|
374 |
+
StandardLightC = 19
|
375 |
+
D55 = 20
|
376 |
+
D65 = 21
|
377 |
+
D75 = 22
|
378 |
+
D50 = 23
|
379 |
+
ISO = 24
|
380 |
+
Other = 255
|
venv/Lib/site-packages/PIL/FitsImagePlugin.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
12 |
+
import math
|
13 |
+
|
14 |
+
from . import Image, ImageFile
|
15 |
+
|
16 |
+
|
17 |
+
def _accept(prefix):
|
18 |
+
return prefix[:6] == b"SIMPLE"
|
19 |
+
|
20 |
+
|
21 |
+
class FitsImageFile(ImageFile.ImageFile):
|
22 |
+
format = "FITS"
|
23 |
+
format_description = "FITS"
|
24 |
+
|
25 |
+
def _open(self):
|
26 |
+
headers = {}
|
27 |
+
while True:
|
28 |
+
header = self.fp.read(80)
|
29 |
+
if not header:
|
30 |
+
msg = "Truncated FITS file"
|
31 |
+
raise OSError(msg)
|
32 |
+
keyword = header[:8].strip()
|
33 |
+
if keyword == b"END":
|
34 |
+
break
|
35 |
+
value = header[8:].split(b"/")[0].strip()
|
36 |
+
if value.startswith(b"="):
|
37 |
+
value = value[1:].strip()
|
38 |
+
if not headers and (not _accept(keyword) or value != b"T"):
|
39 |
+
msg = "Not a FITS file"
|
40 |
+
raise SyntaxError(msg)
|
41 |
+
headers[keyword] = value
|
42 |
+
|
43 |
+
naxis = int(headers[b"NAXIS"])
|
44 |
+
if naxis == 0:
|
45 |
+
msg = "No image data"
|
46 |
+
raise ValueError(msg)
|
47 |
+
elif naxis == 1:
|
48 |
+
self._size = 1, int(headers[b"NAXIS1"])
|
49 |
+
else:
|
50 |
+
self._size = int(headers[b"NAXIS1"]), int(headers[b"NAXIS2"])
|
51 |
+
|
52 |
+
number_of_bits = int(headers[b"BITPIX"])
|
53 |
+
if number_of_bits == 8:
|
54 |
+
self._mode = "L"
|
55 |
+
elif number_of_bits == 16:
|
56 |
+
self._mode = "I"
|
57 |
+
# rawmode = "I;16S"
|
58 |
+
elif number_of_bits == 32:
|
59 |
+
self._mode = "I"
|
60 |
+
elif number_of_bits in (-32, -64):
|
61 |
+
self._mode = "F"
|
62 |
+
# rawmode = "F" if number_of_bits == -32 else "F;64F"
|
63 |
+
|
64 |
+
offset = math.ceil(self.fp.tell() / 2880) * 2880
|
65 |
+
self.tile = [("raw", (0, 0) + self.size, offset, (self.mode, 0, -1))]
|
66 |
+
|
67 |
+
|
68 |
+
# --------------------------------------------------------------------
|
69 |
+
# Registry
|
70 |
+
|
71 |
+
Image.register_open(FitsImageFile.format, FitsImageFile, _accept)
|
72 |
+
|
73 |
+
Image.register_extensions(FitsImageFile.format, [".fit", ".fits"])
|
venv/Lib/site-packages/PIL/FliImagePlugin.py
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
18 |
+
import os
|
19 |
+
|
20 |
+
from . import Image, ImageFile, ImagePalette
|
21 |
+
from ._binary import i16le as i16
|
22 |
+
from ._binary import i32le as i32
|
23 |
+
from ._binary import o8
|
24 |
+
|
25 |
+
#
|
26 |
+
# decoder
|
27 |
+
|
28 |
+
|
29 |
+
def _accept(prefix):
|
30 |
+
return (
|
31 |
+
len(prefix) >= 6
|
32 |
+
and i16(prefix, 4) in [0xAF11, 0xAF12]
|
33 |
+
and i16(prefix, 14) in [0, 3] # flags
|
34 |
+
)
|
35 |
+
|
36 |
+
|
37 |
+
##
|
38 |
+
# Image plugin for the FLI/FLC animation format. Use the <b>seek</b>
|
39 |
+
# method to load individual frames.
|
40 |
+
|
41 |
+
|
42 |
+
class FliImageFile(ImageFile.ImageFile):
|
43 |
+
format = "FLI"
|
44 |
+
format_description = "Autodesk FLI/FLC Animation"
|
45 |
+
_close_exclusive_fp_after_loading = False
|
46 |
+
|
47 |
+
def _open(self):
|
48 |
+
# HEAD
|
49 |
+
s = self.fp.read(128)
|
50 |
+
if not (_accept(s) and s[20:22] == b"\x00\x00"):
|
51 |
+
msg = "not an FLI/FLC file"
|
52 |
+
raise SyntaxError(msg)
|
53 |
+
|
54 |
+
# frames
|
55 |
+
self.n_frames = i16(s, 6)
|
56 |
+
self.is_animated = self.n_frames > 1
|
57 |
+
|
58 |
+
# image characteristics
|
59 |
+
self._mode = "P"
|
60 |
+
self._size = i16(s, 8), i16(s, 10)
|
61 |
+
|
62 |
+
# animation speed
|
63 |
+
duration = i32(s, 16)
|
64 |
+
magic = i16(s, 4)
|
65 |
+
if magic == 0xAF11:
|
66 |
+
duration = (duration * 1000) // 70
|
67 |
+
self.info["duration"] = duration
|
68 |
+
|
69 |
+
# look for palette
|
70 |
+
palette = [(a, a, a) for a in range(256)]
|
71 |
+
|
72 |
+
s = self.fp.read(16)
|
73 |
+
|
74 |
+
self.__offset = 128
|
75 |
+
|
76 |
+
if i16(s, 4) == 0xF100:
|
77 |
+
# prefix chunk; ignore it
|
78 |
+
self.__offset = self.__offset + i32(s)
|
79 |
+
s = self.fp.read(16)
|
80 |
+
|
81 |
+
if i16(s, 4) == 0xF1FA:
|
82 |
+
# look for palette chunk
|
83 |
+
number_of_subchunks = i16(s, 6)
|
84 |
+
chunk_size = None
|
85 |
+
for _ in range(number_of_subchunks):
|
86 |
+
if chunk_size is not None:
|
87 |
+
self.fp.seek(chunk_size - 6, os.SEEK_CUR)
|
88 |
+
s = self.fp.read(6)
|
89 |
+
chunk_type = i16(s, 4)
|
90 |
+
if chunk_type in (4, 11):
|
91 |
+
self._palette(palette, 2 if chunk_type == 11 else 0)
|
92 |
+
break
|
93 |
+
chunk_size = i32(s)
|
94 |
+
if not chunk_size:
|
95 |
+
break
|
96 |
+
|
97 |
+
palette = [o8(r) + o8(g) + o8(b) for (r, g, b) in palette]
|
98 |
+
self.palette = ImagePalette.raw("RGB", b"".join(palette))
|
99 |
+
|
100 |
+
# set things up to decode first frame
|
101 |
+
self.__frame = -1
|
102 |
+
self._fp = self.fp
|
103 |
+
self.__rewind = self.fp.tell()
|
104 |
+
self.seek(0)
|
105 |
+
|
106 |
+
def _palette(self, palette, shift):
|
107 |
+
# load palette
|
108 |
+
|
109 |
+
i = 0
|
110 |
+
for e in range(i16(self.fp.read(2))):
|
111 |
+
s = self.fp.read(2)
|
112 |
+
i = i + s[0]
|
113 |
+
n = s[1]
|
114 |
+
if n == 0:
|
115 |
+
n = 256
|
116 |
+
s = self.fp.read(n * 3)
|
117 |
+
for n in range(0, len(s), 3):
|
118 |
+
r = s[n] << shift
|
119 |
+
g = s[n + 1] << shift
|
120 |
+
b = s[n + 2] << shift
|
121 |
+
palette[i] = (r, g, b)
|
122 |
+
i += 1
|
123 |
+
|
124 |
+
def seek(self, frame):
|
125 |
+
if not self._seek_check(frame):
|
126 |
+
return
|
127 |
+
if frame < self.__frame:
|
128 |
+
self._seek(0)
|
129 |
+
|
130 |
+
for f in range(self.__frame + 1, frame + 1):
|
131 |
+
self._seek(f)
|
132 |
+
|
133 |
+
def _seek(self, frame):
|
134 |
+
if frame == 0:
|
135 |
+
self.__frame = -1
|
136 |
+
self._fp.seek(self.__rewind)
|
137 |
+
self.__offset = 128
|
138 |
+
else:
|
139 |
+
# ensure that the previous frame was loaded
|
140 |
+
self.load()
|
141 |
+
|
142 |
+
if frame != self.__frame + 1:
|
143 |
+
msg = f"cannot seek to frame {frame}"
|
144 |
+
raise ValueError(msg)
|
145 |
+
self.__frame = frame
|
146 |
+
|
147 |
+
# move to next frame
|
148 |
+
self.fp = self._fp
|
149 |
+
self.fp.seek(self.__offset)
|
150 |
+
|
151 |
+
s = self.fp.read(4)
|
152 |
+
if not s:
|
153 |
+
raise EOFError
|
154 |
+
|
155 |
+
framesize = i32(s)
|
156 |
+
|
157 |
+
self.decodermaxblock = framesize
|
158 |
+
self.tile = [("fli", (0, 0) + self.size, self.__offset, None)]
|
159 |
+
|
160 |
+
self.__offset += framesize
|
161 |
+
|
162 |
+
def tell(self):
|
163 |
+
return self.__frame
|
164 |
+
|
165 |
+
|
166 |
+
#
|
167 |
+
# registry
|
168 |
+
|
169 |
+
Image.register_open(FliImageFile.format, FliImageFile, _accept)
|
170 |
+
|
171 |
+
Image.register_extensions(FliImageFile.format, [".fli", ".flc"])
|
venv/Lib/site-packages/PIL/FontFile.py
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# base class for raster font file parsers
|
6 |
+
#
|
7 |
+
# history:
|
8 |
+
# 1997-06-05 fl created
|
9 |
+
# 1997-08-19 fl restrict image width
|
10 |
+
#
|
11 |
+
# Copyright (c) 1997-1998 by Secret Labs AB
|
12 |
+
# Copyright (c) 1997-1998 by Fredrik Lundh
|
13 |
+
#
|
14 |
+
# See the README file for information on usage and redistribution.
|
15 |
+
#
|
16 |
+
|
17 |
+
|
18 |
+
import os
|
19 |
+
|
20 |
+
from . import Image, _binary
|
21 |
+
|
22 |
+
WIDTH = 800
|
23 |
+
|
24 |
+
|
25 |
+
def puti16(fp, values):
|
26 |
+
"""Write network order (big-endian) 16-bit sequence"""
|
27 |
+
for v in values:
|
28 |
+
if v < 0:
|
29 |
+
v += 65536
|
30 |
+
fp.write(_binary.o16be(v))
|
31 |
+
|
32 |
+
|
33 |
+
class FontFile:
|
34 |
+
"""Base class for raster font file handlers."""
|
35 |
+
|
36 |
+
bitmap = None
|
37 |
+
|
38 |
+
def __init__(self):
|
39 |
+
self.info = {}
|
40 |
+
self.glyph = [None] * 256
|
41 |
+
|
42 |
+
def __getitem__(self, ix):
|
43 |
+
return self.glyph[ix]
|
44 |
+
|
45 |
+
def compile(self):
|
46 |
+
"""Create metrics and bitmap"""
|
47 |
+
|
48 |
+
if self.bitmap:
|
49 |
+
return
|
50 |
+
|
51 |
+
# create bitmap large enough to hold all data
|
52 |
+
h = w = maxwidth = 0
|
53 |
+
lines = 1
|
54 |
+
for glyph in self:
|
55 |
+
if glyph:
|
56 |
+
d, dst, src, im = glyph
|
57 |
+
h = max(h, src[3] - src[1])
|
58 |
+
w = w + (src[2] - src[0])
|
59 |
+
if w > WIDTH:
|
60 |
+
lines += 1
|
61 |
+
w = src[2] - src[0]
|
62 |
+
maxwidth = max(maxwidth, w)
|
63 |
+
|
64 |
+
xsize = maxwidth
|
65 |
+
ysize = lines * h
|
66 |
+
|
67 |
+
if xsize == 0 and ysize == 0:
|
68 |
+
return ""
|
69 |
+
|
70 |
+
self.ysize = h
|
71 |
+
|
72 |
+
# paste glyphs into bitmap
|
73 |
+
self.bitmap = Image.new("1", (xsize, ysize))
|
74 |
+
self.metrics = [None] * 256
|
75 |
+
x = y = 0
|
76 |
+
for i in range(256):
|
77 |
+
glyph = self[i]
|
78 |
+
if glyph:
|
79 |
+
d, dst, src, im = glyph
|
80 |
+
xx = src[2] - src[0]
|
81 |
+
# yy = src[3] - src[1]
|
82 |
+
x0, y0 = x, y
|
83 |
+
x = x + xx
|
84 |
+
if x > WIDTH:
|
85 |
+
x, y = 0, y + h
|
86 |
+
x0, y0 = x, y
|
87 |
+
x = xx
|
88 |
+
s = src[0] + x0, src[1] + y0, src[2] + x0, src[3] + y0
|
89 |
+
self.bitmap.paste(im.crop(src), s)
|
90 |
+
self.metrics[i] = d, dst, s
|
91 |
+
|
92 |
+
def save(self, filename):
|
93 |
+
"""Save font"""
|
94 |
+
|
95 |
+
self.compile()
|
96 |
+
|
97 |
+
# font data
|
98 |
+
self.bitmap.save(os.path.splitext(filename)[0] + ".pbm", "PNG")
|
99 |
+
|
100 |
+
# font metrics
|
101 |
+
with open(os.path.splitext(filename)[0] + ".pil", "wb") as fp:
|
102 |
+
fp.write(b"PILfont\n")
|
103 |
+
fp.write(f";;;;;;{self.ysize};\n".encode("ascii")) # HACK!!!
|
104 |
+
fp.write(b"DATA\n")
|
105 |
+
for id in range(256):
|
106 |
+
m = self.metrics[id]
|
107 |
+
if not m:
|
108 |
+
puti16(fp, [0] * 10)
|
109 |
+
else:
|
110 |
+
puti16(fp, m[0] + m[1] + m[2])
|
venv/Lib/site-packages/PIL/FpxImagePlugin.py
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# THIS IS WORK IN PROGRESS
|
3 |
+
#
|
4 |
+
# The Python Imaging Library.
|
5 |
+
# $Id$
|
6 |
+
#
|
7 |
+
# FlashPix support for PIL
|
8 |
+
#
|
9 |
+
# History:
|
10 |
+
# 97-01-25 fl Created (reads uncompressed RGB images only)
|
11 |
+
#
|
12 |
+
# Copyright (c) Secret Labs AB 1997.
|
13 |
+
# Copyright (c) Fredrik Lundh 1997.
|
14 |
+
#
|
15 |
+
# See the README file for information on usage and redistribution.
|
16 |
+
#
|
17 |
+
import olefile
|
18 |
+
|
19 |
+
from . import Image, ImageFile
|
20 |
+
from ._binary import i32le as i32
|
21 |
+
|
22 |
+
# we map from colour field tuples to (mode, rawmode) descriptors
|
23 |
+
MODES = {
|
24 |
+
# opacity
|
25 |
+
(0x00007FFE,): ("A", "L"),
|
26 |
+
# monochrome
|
27 |
+
(0x00010000,): ("L", "L"),
|
28 |
+
(0x00018000, 0x00017FFE): ("RGBA", "LA"),
|
29 |
+
# photo YCC
|
30 |
+
(0x00020000, 0x00020001, 0x00020002): ("RGB", "YCC;P"),
|
31 |
+
(0x00028000, 0x00028001, 0x00028002, 0x00027FFE): ("RGBA", "YCCA;P"),
|
32 |
+
# standard RGB (NIFRGB)
|
33 |
+
(0x00030000, 0x00030001, 0x00030002): ("RGB", "RGB"),
|
34 |
+
(0x00038000, 0x00038001, 0x00038002, 0x00037FFE): ("RGBA", "RGBA"),
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
#
|
39 |
+
# --------------------------------------------------------------------
|
40 |
+
|
41 |
+
|
42 |
+
def _accept(prefix):
|
43 |
+
return prefix[:8] == olefile.MAGIC
|
44 |
+
|
45 |
+
|
46 |
+
##
|
47 |
+
# Image plugin for the FlashPix images.
|
48 |
+
|
49 |
+
|
50 |
+
class FpxImageFile(ImageFile.ImageFile):
|
51 |
+
format = "FPX"
|
52 |
+
format_description = "FlashPix"
|
53 |
+
|
54 |
+
def _open(self):
|
55 |
+
#
|
56 |
+
# read the OLE directory and see if this is a likely
|
57 |
+
# to be a FlashPix file
|
58 |
+
|
59 |
+
try:
|
60 |
+
self.ole = olefile.OleFileIO(self.fp)
|
61 |
+
except OSError as e:
|
62 |
+
msg = "not an FPX file; invalid OLE file"
|
63 |
+
raise SyntaxError(msg) from e
|
64 |
+
|
65 |
+
if self.ole.root.clsid != "56616700-C154-11CE-8553-00AA00A1F95B":
|
66 |
+
msg = "not an FPX file; bad root CLSID"
|
67 |
+
raise SyntaxError(msg)
|
68 |
+
|
69 |
+
self._open_index(1)
|
70 |
+
|
71 |
+
def _open_index(self, index=1):
|
72 |
+
#
|
73 |
+
# get the Image Contents Property Set
|
74 |
+
|
75 |
+
prop = self.ole.getproperties(
|
76 |
+
[f"Data Object Store {index:06d}", "\005Image Contents"]
|
77 |
+
)
|
78 |
+
|
79 |
+
# size (highest resolution)
|
80 |
+
|
81 |
+
self._size = prop[0x1000002], prop[0x1000003]
|
82 |
+
|
83 |
+
size = max(self.size)
|
84 |
+
i = 1
|
85 |
+
while size > 64:
|
86 |
+
size = size / 2
|
87 |
+
i += 1
|
88 |
+
self.maxid = i - 1
|
89 |
+
|
90 |
+
# mode. instead of using a single field for this, flashpix
|
91 |
+
# requires you to specify the mode for each channel in each
|
92 |
+
# resolution subimage, and leaves it to the decoder to make
|
93 |
+
# sure that they all match. for now, we'll cheat and assume
|
94 |
+
# that this is always the case.
|
95 |
+
|
96 |
+
id = self.maxid << 16
|
97 |
+
|
98 |
+
s = prop[0x2000002 | id]
|
99 |
+
|
100 |
+
colors = []
|
101 |
+
bands = i32(s, 4)
|
102 |
+
if bands > 4:
|
103 |
+
msg = "Invalid number of bands"
|
104 |
+
raise OSError(msg)
|
105 |
+
for i in range(bands):
|
106 |
+
# note: for now, we ignore the "uncalibrated" flag
|
107 |
+
colors.append(i32(s, 8 + i * 4) & 0x7FFFFFFF)
|
108 |
+
|
109 |
+
self._mode, self.rawmode = MODES[tuple(colors)]
|
110 |
+
|
111 |
+
# load JPEG tables, if any
|
112 |
+
self.jpeg = {}
|
113 |
+
for i in range(256):
|
114 |
+
id = 0x3000001 | (i << 16)
|
115 |
+
if id in prop:
|
116 |
+
self.jpeg[i] = prop[id]
|
117 |
+
|
118 |
+
self._open_subimage(1, self.maxid)
|
119 |
+
|
120 |
+
def _open_subimage(self, index=1, subimage=0):
|
121 |
+
#
|
122 |
+
# setup tile descriptors for a given subimage
|
123 |
+
|
124 |
+
stream = [
|
125 |
+
f"Data Object Store {index:06d}",
|
126 |
+
f"Resolution {subimage:04d}",
|
127 |
+
"Subimage 0000 Header",
|
128 |
+
]
|
129 |
+
|
130 |
+
fp = self.ole.openstream(stream)
|
131 |
+
|
132 |
+
# skip prefix
|
133 |
+
fp.read(28)
|
134 |
+
|
135 |
+
# header stream
|
136 |
+
s = fp.read(36)
|
137 |
+
|
138 |
+
size = i32(s, 4), i32(s, 8)
|
139 |
+
# tilecount = i32(s, 12)
|
140 |
+
tilesize = i32(s, 16), i32(s, 20)
|
141 |
+
# channels = i32(s, 24)
|
142 |
+
offset = i32(s, 28)
|
143 |
+
length = i32(s, 32)
|
144 |
+
|
145 |
+
if size != self.size:
|
146 |
+
msg = "subimage mismatch"
|
147 |
+
raise OSError(msg)
|
148 |
+
|
149 |
+
# get tile descriptors
|
150 |
+
fp.seek(28 + offset)
|
151 |
+
s = fp.read(i32(s, 12) * length)
|
152 |
+
|
153 |
+
x = y = 0
|
154 |
+
xsize, ysize = size
|
155 |
+
xtile, ytile = tilesize
|
156 |
+
self.tile = []
|
157 |
+
|
158 |
+
for i in range(0, len(s), length):
|
159 |
+
x1 = min(xsize, x + xtile)
|
160 |
+
y1 = min(ysize, y + ytile)
|
161 |
+
|
162 |
+
compression = i32(s, i + 8)
|
163 |
+
|
164 |
+
if compression == 0:
|
165 |
+
self.tile.append(
|
166 |
+
(
|
167 |
+
"raw",
|
168 |
+
(x, y, x1, y1),
|
169 |
+
i32(s, i) + 28,
|
170 |
+
(self.rawmode,),
|
171 |
+
)
|
172 |
+
)
|
173 |
+
|
174 |
+
elif compression == 1:
|
175 |
+
# FIXME: the fill decoder is not implemented
|
176 |
+
self.tile.append(
|
177 |
+
(
|
178 |
+
"fill",
|
179 |
+
(x, y, x1, y1),
|
180 |
+
i32(s, i) + 28,
|
181 |
+
(self.rawmode, s[12:16]),
|
182 |
+
)
|
183 |
+
)
|
184 |
+
|
185 |
+
elif compression == 2:
|
186 |
+
internal_color_conversion = s[14]
|
187 |
+
jpeg_tables = s[15]
|
188 |
+
rawmode = self.rawmode
|
189 |
+
|
190 |
+
if internal_color_conversion:
|
191 |
+
# The image is stored as usual (usually YCbCr).
|
192 |
+
if rawmode == "RGBA":
|
193 |
+
# For "RGBA", data is stored as YCbCrA based on
|
194 |
+
# negative RGB. The following trick works around
|
195 |
+
# this problem :
|
196 |
+
jpegmode, rawmode = "YCbCrK", "CMYK"
|
197 |
+
else:
|
198 |
+
jpegmode = None # let the decoder decide
|
199 |
+
|
200 |
+
else:
|
201 |
+
# The image is stored as defined by rawmode
|
202 |
+
jpegmode = rawmode
|
203 |
+
|
204 |
+
self.tile.append(
|
205 |
+
(
|
206 |
+
"jpeg",
|
207 |
+
(x, y, x1, y1),
|
208 |
+
i32(s, i) + 28,
|
209 |
+
(rawmode, jpegmode),
|
210 |
+
)
|
211 |
+
)
|
212 |
+
|
213 |
+
# FIXME: jpeg tables are tile dependent; the prefix
|
214 |
+
# data must be placed in the tile descriptor itself!
|
215 |
+
|
216 |
+
if jpeg_tables:
|
217 |
+
self.tile_prefix = self.jpeg[jpeg_tables]
|
218 |
+
|
219 |
+
else:
|
220 |
+
msg = "unknown/invalid compression"
|
221 |
+
raise OSError(msg)
|
222 |
+
|
223 |
+
x = x + xtile
|
224 |
+
if x >= xsize:
|
225 |
+
x, y = 0, y + ytile
|
226 |
+
if y >= ysize:
|
227 |
+
break # isn't really required
|
228 |
+
|
229 |
+
self.stream = stream
|
230 |
+
self.fp = None
|
231 |
+
|
232 |
+
def load(self):
|
233 |
+
if not self.fp:
|
234 |
+
self.fp = self.ole.openstream(self.stream[:2] + ["Subimage 0000 Data"])
|
235 |
+
|
236 |
+
return ImageFile.ImageFile.load(self)
|
237 |
+
|
238 |
+
def close(self):
|
239 |
+
self.ole.close()
|
240 |
+
super().close()
|
241 |
+
|
242 |
+
def __exit__(self, *args):
|
243 |
+
self.ole.close()
|
244 |
+
super().__exit__()
|
245 |
+
|
246 |
+
|
247 |
+
#
|
248 |
+
# --------------------------------------------------------------------
|
249 |
+
|
250 |
+
|
251 |
+
Image.register_open(FpxImageFile.format, FpxImageFile, _accept)
|
252 |
+
|
253 |
+
Image.register_extension(FpxImageFile.format, ".fpx")
|
venv/Lib/site-packages/PIL/FtexImagePlugin.py
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
A Pillow loader for .ftc and .ftu files (FTEX)
|
3 |
+
Jerome Leclanche <[email protected]>
|
4 |
+
|
5 |
+
The contents of this file are hereby released in the public domain (CC0)
|
6 |
+
Full text of the CC0 license:
|
7 |
+
https://creativecommons.org/publicdomain/zero/1.0/
|
8 |
+
|
9 |
+
Independence War 2: Edge Of Chaos - Texture File Format - 16 October 2001
|
10 |
+
|
11 |
+
The textures used for 3D objects in Independence War 2: Edge Of Chaos are in a
|
12 |
+
packed custom format called FTEX. This file format uses file extensions FTC
|
13 |
+
and FTU.
|
14 |
+
* FTC files are compressed textures (using standard texture compression).
|
15 |
+
* FTU files are not compressed.
|
16 |
+
Texture File Format
|
17 |
+
The FTC and FTU texture files both use the same format. This
|
18 |
+
has the following structure:
|
19 |
+
{header}
|
20 |
+
{format_directory}
|
21 |
+
{data}
|
22 |
+
Where:
|
23 |
+
{header} = {
|
24 |
+
u32:magic,
|
25 |
+
u32:version,
|
26 |
+
u32:width,
|
27 |
+
u32:height,
|
28 |
+
u32:mipmap_count,
|
29 |
+
u32:format_count
|
30 |
+
}
|
31 |
+
|
32 |
+
* The "magic" number is "FTEX".
|
33 |
+
* "width" and "height" are the dimensions of the texture.
|
34 |
+
* "mipmap_count" is the number of mipmaps in the texture.
|
35 |
+
* "format_count" is the number of texture formats (different versions of the
|
36 |
+
same texture) in this file.
|
37 |
+
|
38 |
+
{format_directory} = format_count * { u32:format, u32:where }
|
39 |
+
|
40 |
+
The format value is 0 for DXT1 compressed textures and 1 for 24-bit RGB
|
41 |
+
uncompressed textures.
|
42 |
+
The texture data for a format starts at the position "where" in the file.
|
43 |
+
|
44 |
+
Each set of texture data in the file has the following structure:
|
45 |
+
{data} = format_count * { u32:mipmap_size, mipmap_size * { u8 } }
|
46 |
+
* "mipmap_size" is the number of bytes in that mip level. For compressed
|
47 |
+
textures this is the size of the texture data compressed with DXT1. For 24 bit
|
48 |
+
uncompressed textures, this is 3 * width * height. Following this are the image
|
49 |
+
bytes for that mipmap level.
|
50 |
+
|
51 |
+
Note: All data is stored in little-Endian (Intel) byte order.
|
52 |
+
"""
|
53 |
+
|
54 |
+
import struct
|
55 |
+
from enum import IntEnum
|
56 |
+
from io import BytesIO
|
57 |
+
|
58 |
+
from . import Image, ImageFile
|
59 |
+
|
60 |
+
MAGIC = b"FTEX"
|
61 |
+
|
62 |
+
|
63 |
+
class Format(IntEnum):
|
64 |
+
DXT1 = 0
|
65 |
+
UNCOMPRESSED = 1
|
66 |
+
|
67 |
+
|
68 |
+
class FtexImageFile(ImageFile.ImageFile):
|
69 |
+
format = "FTEX"
|
70 |
+
format_description = "Texture File Format (IW2:EOC)"
|
71 |
+
|
72 |
+
def _open(self):
|
73 |
+
if not _accept(self.fp.read(4)):
|
74 |
+
msg = "not an FTEX file"
|
75 |
+
raise SyntaxError(msg)
|
76 |
+
struct.unpack("<i", self.fp.read(4)) # version
|
77 |
+
self._size = struct.unpack("<2i", self.fp.read(8))
|
78 |
+
mipmap_count, format_count = struct.unpack("<2i", self.fp.read(8))
|
79 |
+
|
80 |
+
self._mode = "RGB"
|
81 |
+
|
82 |
+
# Only support single-format files.
|
83 |
+
# I don't know of any multi-format file.
|
84 |
+
assert format_count == 1
|
85 |
+
|
86 |
+
format, where = struct.unpack("<2i", self.fp.read(8))
|
87 |
+
self.fp.seek(where)
|
88 |
+
(mipmap_size,) = struct.unpack("<i", self.fp.read(4))
|
89 |
+
|
90 |
+
data = self.fp.read(mipmap_size)
|
91 |
+
|
92 |
+
if format == Format.DXT1:
|
93 |
+
self._mode = "RGBA"
|
94 |
+
self.tile = [("bcn", (0, 0) + self.size, 0, 1)]
|
95 |
+
elif format == Format.UNCOMPRESSED:
|
96 |
+
self.tile = [("raw", (0, 0) + self.size, 0, ("RGB", 0, 1))]
|
97 |
+
else:
|
98 |
+
msg = f"Invalid texture compression format: {repr(format)}"
|
99 |
+
raise ValueError(msg)
|
100 |
+
|
101 |
+
self.fp.close()
|
102 |
+
self.fp = BytesIO(data)
|
103 |
+
|
104 |
+
def load_seek(self, pos):
|
105 |
+
pass
|
106 |
+
|
107 |
+
|
108 |
+
def _accept(prefix):
|
109 |
+
return prefix[:4] == MAGIC
|
110 |
+
|
111 |
+
|
112 |
+
Image.register_open(FtexImageFile.format, FtexImageFile, _accept)
|
113 |
+
Image.register_extensions(FtexImageFile.format, [".ftc", ".ftu"])
|
venv/Lib/site-packages/PIL/GbrImagePlugin.py
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library
|
3 |
+
#
|
4 |
+
# load a GIMP brush file
|
5 |
+
#
|
6 |
+
# History:
|
7 |
+
# 96-03-14 fl Created
|
8 |
+
# 16-01-08 es Version 2
|
9 |
+
#
|
10 |
+
# Copyright (c) Secret Labs AB 1997.
|
11 |
+
# Copyright (c) Fredrik Lundh 1996.
|
12 |
+
# Copyright (c) Eric Soroos 2016.
|
13 |
+
#
|
14 |
+
# See the README file for information on usage and redistribution.
|
15 |
+
#
|
16 |
+
#
|
17 |
+
# See https://github.com/GNOME/gimp/blob/mainline/devel-docs/gbr.txt for
|
18 |
+
# format documentation.
|
19 |
+
#
|
20 |
+
# This code Interprets version 1 and 2 .gbr files.
|
21 |
+
# Version 1 files are obsolete, and should not be used for new
|
22 |
+
# brushes.
|
23 |
+
# Version 2 files are saved by GIMP v2.8 (at least)
|
24 |
+
# Version 3 files have a format specifier of 18 for 16bit floats in
|
25 |
+
# the color depth field. This is currently unsupported by Pillow.
|
26 |
+
|
27 |
+
from . import Image, ImageFile
|
28 |
+
from ._binary import i32be as i32
|
29 |
+
|
30 |
+
|
31 |
+
def _accept(prefix):
|
32 |
+
return len(prefix) >= 8 and i32(prefix, 0) >= 20 and i32(prefix, 4) in (1, 2)
|
33 |
+
|
34 |
+
|
35 |
+
##
|
36 |
+
# Image plugin for the GIMP brush format.
|
37 |
+
|
38 |
+
|
39 |
+
class GbrImageFile(ImageFile.ImageFile):
|
40 |
+
format = "GBR"
|
41 |
+
format_description = "GIMP brush file"
|
42 |
+
|
43 |
+
def _open(self):
|
44 |
+
header_size = i32(self.fp.read(4))
|
45 |
+
if header_size < 20:
|
46 |
+
msg = "not a GIMP brush"
|
47 |
+
raise SyntaxError(msg)
|
48 |
+
version = i32(self.fp.read(4))
|
49 |
+
if version not in (1, 2):
|
50 |
+
msg = f"Unsupported GIMP brush version: {version}"
|
51 |
+
raise SyntaxError(msg)
|
52 |
+
|
53 |
+
width = i32(self.fp.read(4))
|
54 |
+
height = i32(self.fp.read(4))
|
55 |
+
color_depth = i32(self.fp.read(4))
|
56 |
+
if width <= 0 or height <= 0:
|
57 |
+
msg = "not a GIMP brush"
|
58 |
+
raise SyntaxError(msg)
|
59 |
+
if color_depth not in (1, 4):
|
60 |
+
msg = f"Unsupported GIMP brush color depth: {color_depth}"
|
61 |
+
raise SyntaxError(msg)
|
62 |
+
|
63 |
+
if version == 1:
|
64 |
+
comment_length = header_size - 20
|
65 |
+
else:
|
66 |
+
comment_length = header_size - 28
|
67 |
+
magic_number = self.fp.read(4)
|
68 |
+
if magic_number != b"GIMP":
|
69 |
+
msg = "not a GIMP brush, bad magic number"
|
70 |
+
raise SyntaxError(msg)
|
71 |
+
self.info["spacing"] = i32(self.fp.read(4))
|
72 |
+
|
73 |
+
comment = self.fp.read(comment_length)[:-1]
|
74 |
+
|
75 |
+
if color_depth == 1:
|
76 |
+
self._mode = "L"
|
77 |
+
else:
|
78 |
+
self._mode = "RGBA"
|
79 |
+
|
80 |
+
self._size = width, height
|
81 |
+
|
82 |
+
self.info["comment"] = comment
|
83 |
+
|
84 |
+
# Image might not be small
|
85 |
+
Image._decompression_bomb_check(self.size)
|
86 |
+
|
87 |
+
# Data is an uncompressed block of w * h * bytes/pixel
|
88 |
+
self._data_size = width * height * color_depth
|
89 |
+
|
90 |
+
def load(self):
|
91 |
+
if not self.im:
|
92 |
+
self.im = Image.core.new(self.mode, self.size)
|
93 |
+
self.frombytes(self.fp.read(self._data_size))
|
94 |
+
return Image.Image.load(self)
|
95 |
+
|
96 |
+
|
97 |
+
#
|
98 |
+
# registry
|
99 |
+
|
100 |
+
|
101 |
+
Image.register_open(GbrImageFile.format, GbrImageFile, _accept)
|
102 |
+
Image.register_extension(GbrImageFile.format, ".gbr")
|
venv/Lib/site-packages/PIL/GdImageFile.py
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# The Python Imaging Library.
|
3 |
+
# $Id$
|
4 |
+
#
|
5 |
+
# GD file handling
|
6 |
+
#
|
7 |
+
# History:
|
8 |
+
# 1996-04-12 fl Created
|
9 |
+
#
|
10 |
+
# Copyright (c) 1997 by Secret Labs AB.
|
11 |
+
# Copyright (c) 1996 by Fredrik Lundh.
|
12 |
+
#
|
13 |
+
# See the README file for information on usage and redistribution.
|
14 |
+
#
|
15 |
+
|
16 |
+
|
17 |
+
"""
|
18 |
+
.. note::
|
19 |
+
This format cannot be automatically recognized, so the
|
20 |
+
class is not registered for use with :py:func:`PIL.Image.open()`. To open a
|
21 |
+
gd file, use the :py:func:`PIL.GdImageFile.open()` function instead.
|
22 |
+
|
23 |
+
.. warning::
|
24 |
+
THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE. This
|
25 |
+
implementation is provided for convenience and demonstrational
|
26 |
+
purposes only.
|
27 |
+
"""
|
28 |
+
|
29 |
+
|
30 |
+
from . import ImageFile, ImagePalette, UnidentifiedImageError
|
31 |
+
from ._binary import i16be as i16
|
32 |
+
from ._binary import i32be as i32
|
33 |
+
|
34 |
+
|
35 |
+
class GdImageFile(ImageFile.ImageFile):
|
36 |
+
"""
|
37 |
+
Image plugin for the GD uncompressed format. Note that this format
|
38 |
+
is not supported by the standard :py:func:`PIL.Image.open()` function. To use
|
39 |
+
this plugin, you have to import the :py:mod:`PIL.GdImageFile` module and
|
40 |
+
use the :py:func:`PIL.GdImageFile.open()` function.
|
41 |
+
"""
|
42 |
+
|
43 |
+
format = "GD"
|
44 |
+
format_description = "GD uncompressed images"
|
45 |
+
|
46 |
+
def _open(self):
|
47 |
+
# Header
|
48 |
+
s = self.fp.read(1037)
|
49 |
+
|
50 |
+
if i16(s) not in [65534, 65535]:
|
51 |
+
msg = "Not a valid GD 2.x .gd file"
|
52 |
+
raise SyntaxError(msg)
|
53 |
+
|
54 |
+
self._mode = "L" # FIXME: "P"
|
55 |
+
self._size = i16(s, 2), i16(s, 4)
|
56 |
+
|
57 |
+
true_color = s[6]
|
58 |
+
true_color_offset = 2 if true_color else 0
|
59 |
+
|
60 |
+
# transparency index
|
61 |
+
tindex = i32(s, 7 + true_color_offset)
|
62 |
+
if tindex < 256:
|
63 |
+
self.info["transparency"] = tindex
|
64 |
+
|
65 |
+
self.palette = ImagePalette.raw(
|
66 |
+
"XBGR", s[7 + true_color_offset + 4 : 7 + true_color_offset + 4 + 256 * 4]
|
67 |
+
)
|
68 |
+
|
69 |
+
self.tile = [
|
70 |
+
(
|
71 |
+
"raw",
|
72 |
+
(0, 0) + self.size,
|
73 |
+
7 + true_color_offset + 4 + 256 * 4,
|
74 |
+
("L", 0, 1),
|
75 |
+
)
|
76 |
+
]
|
77 |
+
|
78 |
+
|
79 |
+
def open(fp, mode="r"):
|
80 |
+
"""
|
81 |
+
Load texture from a GD image file.
|
82 |
+
|
83 |
+
:param fp: GD file name, or an opened file handle.
|
84 |
+
:param mode: Optional mode. In this version, if the mode argument
|
85 |
+
is given, it must be "r".
|
86 |
+
:returns: An image instance.
|
87 |
+
:raises OSError: If the image could not be read.
|
88 |
+
"""
|
89 |
+
if mode != "r":
|
90 |
+
msg = "bad mode"
|
91 |
+
raise ValueError(msg)
|
92 |
+
|
93 |
+
try:
|
94 |
+
return GdImageFile(fp)
|
95 |
+
except SyntaxError as e:
|
96 |
+
msg = "cannot identify this image file"
|
97 |
+
raise UnidentifiedImageError(msg) from e
|