mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #5316 from radarhere/modes
This commit is contained in:
commit
7785931f43
|
@ -45,6 +45,14 @@ This is now consistent with other IFDs, and must be accessed through
|
||||||
These changes only affect :py:meth:`~PIL.Image.Image.getexif`, introduced in Pillow
|
These changes only affect :py:meth:`~PIL.Image.Image.getexif`, introduced in Pillow
|
||||||
6.0. The older ``_getexif()`` methods are unaffected.
|
6.0. The older ``_getexif()`` methods are unaffected.
|
||||||
|
|
||||||
|
Image._MODEINFO
|
||||||
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This internal dictionary has been deprecated by a comment since PIL, and is now
|
||||||
|
removed. Instead, ``Image.getmodebase()``, ``Image.getmodetype()``,
|
||||||
|
``Image.getmodebandnames()``, ``Image.getmodebands()`` or ``ImageMode.getmode()``
|
||||||
|
can be used.
|
||||||
|
|
||||||
API Additions
|
API Additions
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
|
@ -223,28 +223,7 @@ DECODERS = {}
|
||||||
ENCODERS = {}
|
ENCODERS = {}
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Modes supported by this version
|
# Modes
|
||||||
|
|
||||||
_MODEINFO = {
|
|
||||||
# NOTE: this table will be removed in future versions. use
|
|
||||||
# getmode* functions or ImageMode descriptors instead.
|
|
||||||
# official modes
|
|
||||||
"1": ("L", "L", ("1",)),
|
|
||||||
"L": ("L", "L", ("L",)),
|
|
||||||
"I": ("L", "I", ("I",)),
|
|
||||||
"F": ("L", "F", ("F",)),
|
|
||||||
"P": ("P", "L", ("P",)),
|
|
||||||
"RGB": ("RGB", "L", ("R", "G", "B")),
|
|
||||||
"RGBX": ("RGB", "L", ("R", "G", "B", "X")),
|
|
||||||
"RGBA": ("RGB", "L", ("R", "G", "B", "A")),
|
|
||||||
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
|
|
||||||
"YCbCr": ("RGB", "L", ("Y", "Cb", "Cr")),
|
|
||||||
"LAB": ("RGB", "L", ("L", "A", "B")),
|
|
||||||
"HSV": ("RGB", "L", ("H", "S", "V")),
|
|
||||||
# Experimental modes include I;16, I;16L, I;16B, RGBa, BGR;15, and
|
|
||||||
# BGR;24. Use these modes only if you know exactly what you're
|
|
||||||
# doing...
|
|
||||||
}
|
|
||||||
|
|
||||||
if sys.byteorder == "little":
|
if sys.byteorder == "little":
|
||||||
_ENDIAN = "<"
|
_ENDIAN = "<"
|
||||||
|
@ -290,7 +269,7 @@ def _conv_type_shape(im):
|
||||||
return (im.size[1], im.size[0], extra), typ
|
return (im.size[1], im.size[0], extra), typ
|
||||||
|
|
||||||
|
|
||||||
MODES = sorted(_MODEINFO)
|
MODES = ["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"]
|
||||||
|
|
||||||
# raw modes that may be memory mapped. NOTE: if you change this, you
|
# raw modes that may be memory mapped. NOTE: if you change this, you
|
||||||
# may have to modify the stride calculation in map.c too!
|
# may have to modify the stride calculation in map.c too!
|
||||||
|
|
|
@ -35,18 +35,28 @@ def getmode(mode):
|
||||||
global _modes
|
global _modes
|
||||||
if not _modes:
|
if not _modes:
|
||||||
# initialize mode cache
|
# initialize mode cache
|
||||||
|
|
||||||
from . import Image
|
|
||||||
|
|
||||||
modes = {}
|
modes = {}
|
||||||
# core modes
|
for m, (basemode, basetype, bands) in {
|
||||||
for m, (basemode, basetype, bands) in Image._MODEINFO.items():
|
# core modes
|
||||||
|
"1": ("L", "L", ("1",)),
|
||||||
|
"L": ("L", "L", ("L",)),
|
||||||
|
"I": ("L", "I", ("I",)),
|
||||||
|
"F": ("L", "F", ("F",)),
|
||||||
|
"P": ("P", "L", ("P",)),
|
||||||
|
"RGB": ("RGB", "L", ("R", "G", "B")),
|
||||||
|
"RGBX": ("RGB", "L", ("R", "G", "B", "X")),
|
||||||
|
"RGBA": ("RGB", "L", ("R", "G", "B", "A")),
|
||||||
|
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
|
||||||
|
"YCbCr": ("RGB", "L", ("Y", "Cb", "Cr")),
|
||||||
|
"LAB": ("RGB", "L", ("L", "A", "B")),
|
||||||
|
"HSV": ("RGB", "L", ("H", "S", "V")),
|
||||||
|
# extra experimental modes
|
||||||
|
"RGBa": ("RGB", "L", ("R", "G", "B", "a")),
|
||||||
|
"LA": ("L", "L", ("L", "A")),
|
||||||
|
"La": ("L", "L", ("L", "a")),
|
||||||
|
"PA": ("RGB", "L", ("P", "A")),
|
||||||
|
}.items():
|
||||||
modes[m] = ModeDescriptor(m, bands, basemode, basetype)
|
modes[m] = ModeDescriptor(m, bands, basemode, basetype)
|
||||||
# extra experimental modes
|
|
||||||
modes["RGBa"] = ModeDescriptor("RGBa", ("R", "G", "B", "a"), "RGB", "L")
|
|
||||||
modes["LA"] = ModeDescriptor("LA", ("L", "A"), "L", "L")
|
|
||||||
modes["La"] = ModeDescriptor("La", ("L", "a"), "L", "L")
|
|
||||||
modes["PA"] = ModeDescriptor("PA", ("P", "A"), "RGB", "L")
|
|
||||||
# mapping modes
|
# mapping modes
|
||||||
for i16mode in (
|
for i16mode in (
|
||||||
"I;16",
|
"I;16",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user