Use "gray" more consistently

This commit is contained in:
Andrew Murray 2023-10-19 19:12:01 +11:00
parent 0a6fcc2d97
commit d682c18ded
34 changed files with 80 additions and 80 deletions

View File

@ -2191,7 +2191,7 @@ Changelog (Pillow)
- Cache EXIF information #3498 - Cache EXIF information #3498
[Glandos] [Glandos]
- Added transparency for all PNG greyscale modes #3744 - Added transparency for all PNG grayscale modes #3744
[radarhere] [radarhere]
- Fix deprecation warnings in Python 3.8 #3749 - Fix deprecation warnings in Python 3.8 #3749
@ -4693,7 +4693,7 @@ Changelog (Pillow)
- Fix Bicubic interpolation #970 - Fix Bicubic interpolation #970
[homm] [homm]
- Support for 4-bit greyscale TIFF images #980 - Support for 4-bit grayscale TIFF images #980
[hugovk] [hugovk]
- Updated manifest #957 - Updated manifest #957
@ -6768,7 +6768,7 @@ The test suite includes 750 individual tests.
- You can now convert directly between all modes supported by - You can now convert directly between all modes supported by
PIL. When converting colour images to "P", PIL defaults to PIL. When converting colour images to "P", PIL defaults to
a "web" palette and dithering. When converting greyscale a "web" palette and dithering. When converting grayscale
images to "1", PIL uses a thresholding and dithering. images to "1", PIL uses a thresholding and dithering.
- Added a "dither" option to "convert". By default, "convert" - Added a "dither" option to "convert". By default, "convert"
@ -6846,13 +6846,13 @@ The test suite includes 530 individual tests.
- Fixed "paste" to allow a mask also for mode "F" images. - Fixed "paste" to allow a mask also for mode "F" images.
- The BMP driver now saves mode "1" images. When loading images, the mode - The BMP driver now saves mode "1" images. When loading images, the mode
is set to "L" for 8-bit files with greyscale palettes, and to "P" for is set to "L" for 8-bit files with grayscale palettes, and to "P" for
other 8-bit files. other 8-bit files.
- The IM driver now reads and saves "1" images (file modes "0 1" or "L 1"). - The IM driver now reads and saves "1" images (file modes "0 1" or "L 1").
- The JPEG and GIF drivers now saves "1" images. For JPEG, the image - The JPEG and GIF drivers now saves "1" images. For JPEG, the image
is saved as 8-bit greyscale (it will load as mode "L"). For GIF, the is saved as 8-bit grayscale (it will load as mode "L"). For GIF, the
image will be loaded as a "P" image. image will be loaded as a "P" image.
- Fixed a potential buffer overrun in the GIF encoder. - Fixed a potential buffer overrun in the GIF encoder.
@ -7156,7 +7156,7 @@ The test suite includes 400 individual tests.
drawing capabilities can be used to render vector and metafile drawing capabilities can be used to render vector and metafile
formats. formats.
- Added restricted drivers for images from Image Tools (greyscale - Added restricted drivers for images from Image Tools (grayscale
only) and LabEye/IFUNC (common interchange modes only). only) and LabEye/IFUNC (common interchange modes only).
- Some minor improvements to the sample scripts provided in the - Some minor improvements to the sample scripts provided in the

View File

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View File

Before

Width:  |  Height:  |  Size: 668 B

After

Width:  |  Height:  |  Size: 668 B

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -231,13 +231,13 @@ def test_apng_mode():
assert im.getpixel((0, 0)) == (0, 0, 128, 191) assert im.getpixel((0, 0)) == (0, 0, 128, 191)
assert im.getpixel((64, 32)) == (0, 0, 128, 191) assert im.getpixel((64, 32)) == (0, 0, 128, 191)
with Image.open("Tests/images/apng/mode_greyscale.png") as im: with Image.open("Tests/images/apng/mode_grayscale.png") as im:
assert im.mode == "L" assert im.mode == "L"
im.seek(im.n_frames - 1) im.seek(im.n_frames - 1)
assert im.getpixel((0, 0)) == 128 assert im.getpixel((0, 0)) == 128
assert im.getpixel((64, 32)) == 255 assert im.getpixel((64, 32)) == 255
with Image.open("Tests/images/apng/mode_greyscale_alpha.png") as im: with Image.open("Tests/images/apng/mode_grayscale_alpha.png") as im:
assert im.mode == "LA" assert im.mode == "LA"
im.seek(im.n_frames - 1) im.seek(im.n_frames - 1)
assert im.getpixel((0, 0)) == (128, 191) assert im.getpixel((0, 0)) == (128, 191)

View File

@ -159,7 +159,7 @@ def test_rle8():
with Image.open("Tests/images/hopper_rle8.bmp") as im: with Image.open("Tests/images/hopper_rle8.bmp") as im:
assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12) assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12)
with Image.open("Tests/images/hopper_rle8_greyscale.bmp") as im: with Image.open("Tests/images/hopper_rle8_grayscale.bmp") as im:
assert_image_equal_tofile(im, "Tests/images/bw_gradient.png") assert_image_equal_tofile(im, "Tests/images/bw_gradient.png")
# This test image has been manually hexedited # This test image has been manually hexedited

View File

@ -590,7 +590,7 @@ def test_save_dispose(tmp_path):
def test_dispose2_palette(tmp_path): def test_dispose2_palette(tmp_path):
out = str(tmp_path / "temp.gif") out = str(tmp_path / "temp.gif")
# Four colors: white, grey, black, red # Four colors: white, gray, black, red
circles = [(255, 255, 255), (153, 153, 153), (0, 0, 0), (255, 0, 0)] circles = [(255, 255, 255), (153, 153, 153), (0, 0, 0), (255, 0, 0)]
im_list = [] im_list = []

View File

@ -297,7 +297,7 @@ class TestFilePng:
assert_image(im, "RGBA", (10, 10)) assert_image(im, "RGBA", (10, 10))
assert im.getcolors() == [(100, (0, 0, 0, 0))] assert im.getcolors() == [(100, (0, 0, 0, 0))]
def test_save_greyscale_transparency(self, tmp_path): def test_save_grayscale_transparency(self, tmp_path):
for mode, num_transparent in {"1": 1994, "L": 559, "I": 559}.items(): for mode, num_transparent in {"1": 1994, "L": 559, "I": 559}.items():
in_file = "Tests/images/" + mode.lower() + "_trns.png" in_file = "Tests/images/" + mode.lower() + "_trns.png"
with Image.open(in_file) as im: with Image.open(in_file) as im:

View File

@ -10,7 +10,7 @@ GREEN = (0, 255, 0)
ORANGE = (255, 128, 0) ORANGE = (255, 128, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
GREY = 128 GRAY = 128
def test_sanity(): def test_sanity():
@ -121,12 +121,12 @@ def test_constant():
im = Image.new("RGB", (20, 10)) im = Image.new("RGB", (20, 10))
# Act # Act
new = ImageChops.constant(im, GREY) new = ImageChops.constant(im, GRAY)
# Assert # Assert
assert new.size == im.size assert new.size == im.size
assert new.getpixel((0, 0)) == GREY assert new.getpixel((0, 0)) == GRAY
assert new.getpixel((19, 9)) == GREY assert new.getpixel((19, 9)) == GRAY
def test_darker_image(): def test_darker_image():

View File

@ -303,8 +303,8 @@ def test_multiline_spacing(font):
"orientation", (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270) "orientation", (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270)
) )
def test_rotated_transposed_font(font, orientation): def test_rotated_transposed_font(font, orientation):
img_grey = Image.new("L", (100, 100)) img_gray = Image.new("L", (100, 100))
draw = ImageDraw.Draw(img_grey) draw = ImageDraw.Draw(img_gray)
word = "testing" word = "testing"
transposed_font = ImageFont.TransposedFont(font, orientation=orientation) transposed_font = ImageFont.TransposedFont(font, orientation=orientation)
@ -344,8 +344,8 @@ def test_rotated_transposed_font(font, orientation):
), ),
) )
def test_unrotated_transposed_font(font, orientation): def test_unrotated_transposed_font(font, orientation):
img_grey = Image.new("L", (100, 100)) img_gray = Image.new("L", (100, 100))
draw = ImageDraw.Draw(img_grey) draw = ImageDraw.Draw(img_gray)
word = "testing" word = "testing"
transposed_font = ImageFont.TransposedFont(font, orientation=orientation) transposed_font = ImageFont.TransposedFont(font, orientation=orientation)

View File

@ -26,7 +26,7 @@ image. If the image was not read from a file, it is set to None. The size
attribute is a 2-tuple containing width and height (in pixels). The attribute is a 2-tuple containing width and height (in pixels). The
:py:attr:`~PIL.Image.Image.mode` attribute defines the number and names of the :py:attr:`~PIL.Image.Image.mode` attribute defines the number and names of the
bands in the image, and also the pixel type and depth. Common modes are “L” bands in the image, and also the pixel type and depth. Common modes are “L”
(luminance) for greyscale images, “RGB” for true color images, and “CMYK” for (luminance) for grayscale images, “RGB” for true color images, and “CMYK” for
pre-press images. pre-press images.
If the file cannot be opened, an :py:exc:`OSError` exception is raised. If the file cannot be opened, an :py:exc:`OSError` exception is raised.
@ -599,7 +599,7 @@ Controlling the decoder
Some decoders allow you to manipulate the image while reading it from a file. Some decoders allow you to manipulate the image while reading it from a file.
This can often be used to speed up decoding when creating thumbnails (when This can often be used to speed up decoding when creating thumbnails (when
speed is usually more important than quality) and printing to a monochrome speed is usually more important than quality) and printing to a monochrome
laser printer (when only a greyscale version of the image is needed). laser printer (when only a grayscale version of the image is needed).
The :py:meth:`~PIL.Image.Image.draft` method manipulates an opened but not yet The :py:meth:`~PIL.Image.Image.draft` method manipulates an opened but not yet
loaded image so it as closely as possible matches the given mode and size. This loaded image so it as closely as possible matches the given mode and size. This

View File

@ -45,7 +45,7 @@ Example
The following plugin supports a simple format, which has a 128-byte header The following plugin supports a simple format, which has a 128-byte header
consisting of the words “SPAM” followed by the width, height, and pixel size in consisting of the words “SPAM” followed by the width, height, and pixel size in
bits. The header fields are separated by spaces. The image data follows bits. The header fields are separated by spaces. The image data follows
directly after the header, and can be either bi-level, greyscale, or 24-bit directly after the header, and can be either bi-level, grayscale, or 24-bit
true color. true color.
**SpamImagePlugin.py**:: **SpamImagePlugin.py**::
@ -211,9 +211,9 @@ table describes some commonly used **raw modes**:
| ``1;R`` | | 1-bit reversed bilevel, stored with the leftmost pixel in the | | ``1;R`` | | 1-bit reversed bilevel, stored with the leftmost pixel in the |
| | | least significant bit. 0 means black, 1 means white. | | | | least significant bit. 0 means black, 1 means white. |
+-----------+-------------------------------------------------------------------+ +-----------+-------------------------------------------------------------------+
| ``L`` | 8-bit greyscale. 0 means black, 255 means white. | | ``L`` | 8-bit grayscale. 0 means black, 255 means white. |
+-----------+-------------------------------------------------------------------+ +-----------+-------------------------------------------------------------------+
| ``L;I`` | 8-bit inverted greyscale. 0 means white, 255 means black. | | ``L;I`` | 8-bit inverted grayscale. 0 means white, 255 means black. |
+-----------+-------------------------------------------------------------------+ +-----------+-------------------------------------------------------------------+
| ``P`` | 8-bit palette-mapped image. | | ``P`` | 8-bit palette-mapped image. |
+-----------+-------------------------------------------------------------------+ +-----------+-------------------------------------------------------------------+

View File

@ -59,7 +59,7 @@ Functions
.. py:method:: getcolor(color, mode) .. py:method:: getcolor(color, mode)
Same as :py:func:`~PIL.ImageColor.getrgb`, but converts the RGB value to a Same as :py:func:`~PIL.ImageColor.getrgb`, but converts the RGB value to a
greyscale value if the mode is not color or a palette image. If the string grayscale value if the mode is not color or a palette image. If the string
cannot be parsed, this function raises a :py:exc:`ValueError` exception. cannot be parsed, this function raises a :py:exc:`ValueError` exception.
.. versionadded:: 1.1.4 .. versionadded:: 1.1.4

View File

@ -58,7 +58,7 @@ method:
This class can be used to control the contrast of an image, similar to the This class can be used to control the contrast of an image, similar to the
contrast control on a TV set. An contrast control on a TV set. An
:ref:`enhancement factor <enhancement-factor>` of 0.0 gives a solid grey :ref:`enhancement factor <enhancement-factor>` of 0.0 gives a solid gray
image, a factor of 1.0 gives the original image, and greater values image, a factor of 1.0 gives the original image, and greater values
increase the contrast of the image. increase the contrast of the image.

View File

@ -72,7 +72,7 @@ pixel bits.
Note that the operands are converted to 32-bit signed integers before the Note that the operands are converted to 32-bit signed integers before the
bitwise operation is applied. This means that youll get negative values if bitwise operation is applied. This means that youll get negative values if
you invert an ordinary greyscale image. You can use the and (&) operator to you invert an ordinary grayscale image. You can use the and (&) operator to
mask off unwanted bits. mask off unwanted bits.
Bitwise operators dont work on floating point images. Bitwise operators dont work on floating point images.

View File

@ -29,10 +29,10 @@ API Additions
Image.entropy Image.entropy
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Calculates and returns the entropy for the image. A bilevel image (mode "1") is treated Calculates and returns the entropy for the image. A bilevel image (mode "1") is treated
as a greyscale ("L") image by this method. If a mask is provided, the method employs as a grayscale ("L") image by this method. If a mask is provided, the method employs
the histogram for those parts of the image where the mask image is non-zero. The mask the histogram for those parts of the image where the mask image is non-zero. The mask
image must have the same size as the image, and be either a bi-level image (mode "1") or image must have the same size as the image, and be either a bi-level image (mode "1") or
a greyscale image ("L"). a grayscale image ("L").
ImageGrab.grab ImageGrab.grab
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^

View File

@ -230,21 +230,21 @@ class BmpImageFile(ImageFile.ImageFile):
else: else:
padding = file_info["palette_padding"] padding = file_info["palette_padding"]
palette = read(padding * file_info["colors"]) palette = read(padding * file_info["colors"])
greyscale = True grayscale = True
indices = ( indices = (
(0, 255) (0, 255)
if file_info["colors"] == 2 if file_info["colors"] == 2
else list(range(file_info["colors"])) else list(range(file_info["colors"]))
) )
# ----------------- Check if greyscale and ignore palette if so # ----------------- Check if grayscale and ignore palette if so
for ind, val in enumerate(indices): for ind, val in enumerate(indices):
rgb = palette[ind * padding : ind * padding + 3] rgb = palette[ind * padding : ind * padding + 3]
if rgb != o8(val) * 3: if rgb != o8(val) * 3:
greyscale = False grayscale = False
# ------- If all colors are grey, white or black, ditch palette # ------- If all colors are gray, white or black, ditch palette
if greyscale: if grayscale:
self._mode = "1" if file_info["colors"] == 2 else "L" self._mode = "1" if file_info["colors"] == 2 else "L"
raw_mode = self.mode raw_mode = self.mode
else: else:

View File

@ -878,12 +878,12 @@ class Image:
"L", "RGB" and "CMYK". The ``matrix`` argument only supports "L" "L", "RGB" and "CMYK". The ``matrix`` argument only supports "L"
and "RGB". and "RGB".
When translating a color image to greyscale (mode "L"), When translating a color image to grayscale (mode "L"),
the library uses the ITU-R 601-2 luma transform:: the library uses the ITU-R 601-2 luma transform::
L = R * 299/1000 + G * 587/1000 + B * 114/1000 L = R * 299/1000 + G * 587/1000 + B * 114/1000
The default method of converting a greyscale ("L") or "RGB" The default method of converting a grayscale ("L") or "RGB"
image into a bilevel (mode "1") image uses Floyd-Steinberg image into a bilevel (mode "1") image uses Floyd-Steinberg
dither to approximate the original image luminosity levels. If dither to approximate the original image luminosity levels. If
dither is ``None``, all values larger than 127 are set to 255 (white), dither is ``None``, all values larger than 127 are set to 255 (white),
@ -1238,7 +1238,7 @@ class Image:
Configures the image file loader so it returns a version of the Configures the image file loader so it returns a version of the
image that as closely as possible matches the given mode and image that as closely as possible matches the given mode and
size. For example, you can use this method to convert a color size. For example, you can use this method to convert a color
JPEG to greyscale while loading it. JPEG to grayscale while loading it.
If any changes are made, returns a tuple with the chosen ``mode`` and If any changes are made, returns a tuple with the chosen ``mode`` and
``box`` with coordinates of the original image within the altered one. ``box`` with coordinates of the original image within the altered one.
@ -1610,13 +1610,13 @@ class Image:
than one band, the histograms for all bands are concatenated (for than one band, the histograms for all bands are concatenated (for
example, the histogram for an "RGB" image contains 768 values). example, the histogram for an "RGB" image contains 768 values).
A bilevel image (mode "1") is treated as a greyscale ("L") image A bilevel image (mode "1") is treated as a grayscale ("L") image
by this method. by this method.
If a mask is provided, the method returns a histogram for those If a mask is provided, the method returns a histogram for those
parts of the image where the mask image is non-zero. The mask parts of the image where the mask image is non-zero. The mask
image must have the same size as the image, and be either a image must have the same size as the image, and be either a
bi-level image (mode "1") or a greyscale image ("L"). bi-level image (mode "1") or a grayscale image ("L").
:param mask: An optional mask. :param mask: An optional mask.
:param extrema: An optional tuple of manually-specified extrema. :param extrema: An optional tuple of manually-specified extrema.
@ -1636,13 +1636,13 @@ class Image:
""" """
Calculates and returns the entropy for the image. Calculates and returns the entropy for the image.
A bilevel image (mode "1") is treated as a greyscale ("L") A bilevel image (mode "1") is treated as a grayscale ("L")
image by this method. image by this method.
If a mask is provided, the method employs the histogram for If a mask is provided, the method employs the histogram for
those parts of the image where the mask image is non-zero. those parts of the image where the mask image is non-zero.
The mask image must have the same size as the image, and be The mask image must have the same size as the image, and be
either a bi-level image (mode "1") or a greyscale image ("L"). either a bi-level image (mode "1") or a grayscale image ("L").
:param mask: An optional mask. :param mask: An optional mask.
:param extrema: An optional tuple of manually-specified extrema. :param extrema: An optional tuple of manually-specified extrema.
@ -2874,7 +2874,7 @@ class ImageTransformHandler:
def _wedge(): def _wedge():
"""Create greyscale wedge (for debugging only)""" """Create grayscale wedge (for debugging only)"""
return Image()._new(core.wedge("L")) return Image()._new(core.wedge("L"))

View File

@ -19,7 +19,7 @@ from . import Image
def constant(image, value): def constant(image, value):
"""Fill a channel with a given grey level. """Fill a channel with a given gray level.
:rtype: :py:class:`~PIL.Image.Image` :rtype: :py:class:`~PIL.Image.Image`
""" """

View File

@ -124,7 +124,7 @@ def getcolor(color, mode):
""" """
Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if
``mode`` is HSV, converts the RGB value to a HSV value, or if ``mode`` is ``mode`` is HSV, converts the RGB value to a HSV value, or if ``mode`` is
not color or a palette image, converts the RGB value to a greyscale value. not color or a palette image, converts the RGB value to a grayscale value.
If the string cannot be parsed, this function raises a :py:exc:`ValueError` If the string cannot be parsed, this function raises a :py:exc:`ValueError`
exception. exception.

View File

@ -59,7 +59,7 @@ class Contrast(_Enhance):
This class can be used to control the contrast of an image, similar This class can be used to control the contrast of an image, similar
to the contrast control on a TV set. An enhancement factor of 0.0 to the contrast control on a TV set. An enhancement factor of 0.0
gives a solid grey image. A factor of 1.0 gives the original image. gives a solid gray image. A factor of 1.0 gives the original image.
""" """
def __init__(self, image): def __init__(self, image):

View File

@ -593,7 +593,7 @@ def solarize(image, threshold=128):
Invert all pixel values above a threshold. Invert all pixel values above a threshold.
:param image: The image to solarize. :param image: The image to solarize.
:param threshold: All pixels above this greyscale level are inverted. :param threshold: All pixels above this grayscale level are inverted.
:return: An image. :return: An image.
""" """
lut = [] lut = []

View File

@ -54,9 +54,9 @@ class Dib:
"L", "P", or "RGB". "L", "P", or "RGB".
If the display requires a palette, this constructor creates a suitable If the display requires a palette, this constructor creates a suitable
palette and associates it with the image. For an "L" image, 128 greylevels palette and associates it with the image. For an "L" image, 128 graylevels
are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
with 20 greylevels. with 20 graylevels.
To make sure that palettes work properly under Windows, you must call the To make sure that palettes work properly under Windows, you must call the
``palette`` method upon certain events from Windows. ``palette`` method upon certain events from Windows.

View File

@ -109,7 +109,7 @@ class PSDraw:
if im.mode == "1": if im.mode == "1":
dpi = 200 # fax dpi = 200 # fax
else: else:
dpi = 100 # greyscale dpi = 100 # grayscale
# image size (on paper) # image size (on paper)
x = im.size[0] * 72 / dpi x = im.size[0] * 72 / dpi
y = im.size[1] * 72 / dpi y = im.size[1] * 72 / dpi

View File

@ -124,7 +124,7 @@ def _save(im, fp, filename):
if im.encoderinfo.get("bpp") in (1, 2, 4): if im.encoderinfo.get("bpp") in (1, 2, 4):
# this is 8-bit grayscale, so we shift it to get the high-order bits, # this is 8-bit grayscale, so we shift it to get the high-order bits,
# and invert it because # and invert it because
# Palm does greyscale from white (0) to black (1) # Palm does grayscale from white (0) to black (1)
bpp = im.encoderinfo["bpp"] bpp = im.encoderinfo["bpp"]
im = im.point( im = im.point(
lambda x, shift=8 - bpp, maxval=(1 << bpp) - 1: maxval - (x >> shift) lambda x, shift=8 - bpp, maxval=(1 << bpp) - 1: maxval - (x >> shift)

View File

@ -91,7 +91,7 @@ class PcxImageFile(ImageFile.ImageFile):
self.fp.seek(-769, io.SEEK_END) self.fp.seek(-769, io.SEEK_END)
s = self.fp.read(769) s = self.fp.read(769)
if len(s) == 769 and s[0] == 12: if len(s) == 769 and s[0] == 12:
# check if the palette is linear greyscale # check if the palette is linear grayscale
for i in range(256): for i in range(256):
if s[i * 3 + 1 : i * 3 + 4] != o8(i) * 3: if s[i * 3 + 1 : i * 3 + 4] != o8(i) * 3:
mode = rawmode = "P" mode = rawmode = "P"
@ -203,7 +203,7 @@ def _save(im, fp, filename):
palette += b"\x00" * (768 - len(palette)) palette += b"\x00" * (768 - len(palette))
fp.write(palette) # 768 bytes fp.write(palette) # 768 bytes
elif im.mode == "L": elif im.mode == "L":
# greyscale palette # grayscale palette
fp.write(o8(12)) fp.write(o8(12))
for i in range(256): for i in range(256):
fp.write(o8(i) * 3) fp.write(o8(i) * 3)

View File

@ -56,7 +56,7 @@ _MAGIC = b"\211PNG\r\n\032\n"
_MODES = { _MODES = {
# supported bits/color combinations, and corresponding modes/rawmodes # supported bits/color combinations, and corresponding modes/rawmodes
# Greyscale # Grayscale
(1, 0): ("1", "1"), (1, 0): ("1", "1"),
(2, 0): ("L", "L;2"), (2, 0): ("L", "L;2"),
(4, 0): ("L", "L;4"), (4, 0): ("L", "L;4"),
@ -70,7 +70,7 @@ _MODES = {
(2, 3): ("P", "P;2"), (2, 3): ("P", "P;2"),
(4, 3): ("P", "P;4"), (4, 3): ("P", "P;4"),
(8, 3): ("P", "P"), (8, 3): ("P", "P"),
# Greyscale with alpha # Grayscale with alpha
(8, 4): ("LA", "LA"), (8, 4): ("LA", "LA"),
(16, 4): ("RGBA", "LA;16B"), # LA;16B->LA not yet available (16, 4): ("RGBA", "LA;16B"), # LA;16B->LA not yet available
# Truecolour with alpha # Truecolour with alpha

View File

@ -1013,7 +1013,7 @@ static struct {
static void static void
p2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { p2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++) { for (x = 0; x < xsize; x++) {
*out++ = (L(&palette->palette[in[x] * 4]) >= 128000) ? 255 : 0; *out++ = (L(&palette->palette[in[x] * 4]) >= 128000) ? 255 : 0;
} }
@ -1022,7 +1022,7 @@ p2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
static void static void
pa2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { pa2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++, in += 4) { for (x = 0; x < xsize; x++, in += 4) {
*out++ = (L(&palette->palette[in[0] * 4]) >= 128000) ? 255 : 0; *out++ = (L(&palette->palette[in[0] * 4]) >= 128000) ? 255 : 0;
} }
@ -1031,7 +1031,7 @@ pa2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
static void static void
p2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { p2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++) { for (x = 0; x < xsize; x++) {
*out++ = L24(&palette->palette[in[x] * 4]) >> 16; *out++ = L24(&palette->palette[in[x] * 4]) >> 16;
} }
@ -1040,7 +1040,7 @@ p2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
static void static void
pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++, in += 4) { for (x = 0; x < xsize; x++, in += 4) {
*out++ = L24(&palette->palette[in[0] * 4]) >> 16; *out++ = L24(&palette->palette[in[0] * 4]) >> 16;
} }
@ -1070,7 +1070,7 @@ p2pa(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
static void static void
p2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { p2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++, out += 4) { for (x = 0; x < xsize; x++, out += 4) {
const UINT8 *rgba = &palette->palette[*in++ * 4]; const UINT8 *rgba = &palette->palette[*in++ * 4];
out[0] = out[1] = out[2] = L24(rgba) >> 16; out[0] = out[1] = out[2] = L24(rgba) >> 16;
@ -1081,7 +1081,7 @@ p2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
static void static void
pa2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { pa2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x; int x;
/* FIXME: precalculate greyscale palette? */ /* FIXME: precalculate grayscale palette? */
for (x = 0; x < xsize; x++, in += 4, out += 4) { for (x = 0; x < xsize; x++, in += 4, out += 4) {
out[0] = out[1] = out[2] = L24(&palette->palette[in[0] * 4]) >> 16; out[0] = out[1] = out[2] = L24(&palette->palette[in[0] * 4]) >> 16;
out[3] = in[3]; out[3] = in[3];
@ -1335,9 +1335,9 @@ topalette(
imOut->palette = ImagingPaletteDuplicate(palette); imOut->palette = ImagingPaletteDuplicate(palette);
if (imIn->bands == 1) { if (imIn->bands == 1) {
/* greyscale image */ /* grayscale image */
/* Greyscale palette: copy data as is */ /* Grayscale palette: copy data as is */
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
for (y = 0; y < imIn->ysize; y++) { for (y = 0; y < imIn->ysize; y++) {
if (alpha) { if (alpha) {

View File

@ -142,9 +142,9 @@ ImagingNewDIB(const char *mode, int xsize, int ysize) {
GetSystemPaletteEntries(dib->dc, 0, 256, pal->palPalEntry); GetSystemPaletteEntries(dib->dc, 0, 256, pal->palPalEntry);
if (strcmp(mode, "L") == 0) { if (strcmp(mode, "L") == 0) {
/* Greyscale DIB. Fill all 236 slots with a greyscale ramp /* Grayscale DIB. Fill all 236 slots with a grayscale ramp
* (this is usually overkill on Windows since VGA only offers * (this is usually overkill on Windows since VGA only offers
* 6 bits greyscale resolution). Ignore the slots already * 6 bits grayscale resolution). Ignore the slots already
* allocated by Windows */ * allocated by Windows */
i = 10; i = 10;
@ -160,7 +160,7 @@ ImagingNewDIB(const char *mode, int xsize, int ysize) {
#ifdef CUBE216 #ifdef CUBE216
/* Colour DIB. Create a 6x6x6 colour cube (216 entries) and /* Colour DIB. Create a 6x6x6 colour cube (216 entries) and
* add 20 extra greylevels for best result with greyscale * add 20 extra graylevels for best result with grayscale
* images. */ * images. */
i = 10; i = 10;

View File

@ -549,16 +549,16 @@ static struct {
{"1", "1;IR", 1, pack1IR}, {"1", "1;IR", 1, pack1IR},
{"1", "L", 8, pack1L}, {"1", "L", 8, pack1L},
/* greyscale */ /* grayscale */
{"L", "L", 8, copy1}, {"L", "L", 8, copy1},
{"L", "L;16", 16, packL16}, {"L", "L;16", 16, packL16},
{"L", "L;16B", 16, packL16B}, {"L", "L;16B", 16, packL16B},
/* greyscale w. alpha */ /* grayscale w. alpha */
{"LA", "LA", 16, packLA}, {"LA", "LA", 16, packLA},
{"LA", "LA;L", 16, packLAL}, {"LA", "LA;L", 16, packLAL},
/* greyscale w. alpha premultiplied */ /* grayscale w. alpha premultiplied */
{"La", "La", 16, packLA}, {"La", "La", 16, packLA},
/* palette */ /* palette */

View File

@ -75,7 +75,7 @@ ImagingPaletteNewBrowser(void) {
} }
palette->size = i; palette->size = i;
/* FIXME: add 30-level greyscale wedge here? */ /* FIXME: add 30-level grayscale wedge here? */
return palette; return palette;
} }

View File

@ -1697,7 +1697,7 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans) {
image data? */ image data? */
if (!strcmp(im->mode, "L")) { if (!strcmp(im->mode, "L")) {
/* greyscale */ /* grayscale */
/* FIXME: converting a "L" image to "P" with 256 colors /* FIXME: converting a "L" image to "P" with 256 colors
should be done by a simple copy... */ should be done by a simple copy... */

View File

@ -80,18 +80,18 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size) {
im->palette = ImagingPaletteNew("RGB"); im->palette = ImagingPaletteNew("RGB");
} else if (strcmp(mode, "L") == 0) { } else if (strcmp(mode, "L") == 0) {
/* 8-bit greyscale (luminance) images */ /* 8-bit grayscale (luminance) images */
im->bands = im->pixelsize = 1; im->bands = im->pixelsize = 1;
im->linesize = xsize; im->linesize = xsize;
} else if (strcmp(mode, "LA") == 0) { } else if (strcmp(mode, "LA") == 0) {
/* 8-bit greyscale (luminance) with alpha */ /* 8-bit grayscale (luminance) with alpha */
im->bands = 2; im->bands = 2;
im->pixelsize = 4; /* store in image32 memory */ im->pixelsize = 4; /* store in image32 memory */
im->linesize = xsize * 4; im->linesize = xsize * 4;
} else if (strcmp(mode, "La") == 0) { } else if (strcmp(mode, "La") == 0) {
/* 8-bit greyscale (luminance) with premultiplied alpha */ /* 8-bit grayscale (luminance) with premultiplied alpha */
im->bands = 2; im->bands = 2;
im->pixelsize = 4; /* store in image32 memory */ im->pixelsize = 4; /* store in image32 memory */
im->linesize = xsize * 4; im->linesize = xsize * 4;

View File

@ -819,7 +819,7 @@ ImagingUnpackXBGR(UINT8 *_out, const UINT8 *in, int pixels) {
static void static void
unpackRGBALA(UINT8 *_out, const UINT8 *in, int pixels) { unpackRGBALA(UINT8 *_out, const UINT8 *in, int pixels) {
int i; int i;
/* greyscale with alpha */ /* grayscale with alpha */
for (i = 0; i < pixels; i++) { for (i = 0; i < pixels; i++) {
UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[1]); UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[1]);
memcpy(_out, &iv, sizeof(iv)); memcpy(_out, &iv, sizeof(iv));
@ -831,7 +831,7 @@ unpackRGBALA(UINT8 *_out, const UINT8 *in, int pixels) {
static void static void
unpackRGBALA16B(UINT8 *_out, const UINT8 *in, int pixels) { unpackRGBALA16B(UINT8 *_out, const UINT8 *in, int pixels) {
int i; int i;
/* 16-bit greyscale with alpha, big-endian */ /* 16-bit grayscale with alpha, big-endian */
for (i = 0; i < pixels; i++) { for (i = 0; i < pixels; i++) {
UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[2]); UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[2]);
memcpy(_out, &iv, sizeof(iv)); memcpy(_out, &iv, sizeof(iv));
@ -1108,7 +1108,7 @@ unpackCMYKI(UINT8 *_out, const UINT8 *in, int pixels) {
/* There are two representations of LAB images for whatever precision: /* There are two representations of LAB images for whatever precision:
L: Uint (in PS, it's 0-100) L: Uint (in PS, it's 0-100)
A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle. A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle.
Channels in PS display a 0 value as middle grey, Channels in PS display a 0 value as middle gray,
LCMS appears to use 128 as the 0 value for these channels) LCMS appears to use 128 as the 0 value for these channels)
B: Int (as above) B: Int (as above)
@ -1172,7 +1172,7 @@ unpackI16R_I16(UINT8 *out, const UINT8 *in, int pixels) {
static void static void
unpackI12_I16(UINT8 *out, const UINT8 *in, int pixels) { unpackI12_I16(UINT8 *out, const UINT8 *in, int pixels) {
/* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs. /* Fillorder 1/MSB -> LittleEndian, for 12bit integer grayscale tiffs.
According to the TIFF spec: According to the TIFF spec:
@ -1527,7 +1527,7 @@ static struct {
{"1", "1;IR", 1, unpack1IR}, {"1", "1;IR", 1, unpack1IR},
{"1", "1;8", 8, unpack18}, {"1", "1;8", 8, unpack18},
/* greyscale */ /* grayscale */
{"L", "L;2", 2, unpackL2}, {"L", "L;2", 2, unpackL2},
{"L", "L;2I", 2, unpackL2I}, {"L", "L;2I", 2, unpackL2I},
{"L", "L;2R", 2, unpackL2R}, {"L", "L;2R", 2, unpackL2R},
@ -1544,11 +1544,11 @@ static struct {
{"L", "L;16", 16, unpackL16}, {"L", "L;16", 16, unpackL16},
{"L", "L;16B", 16, unpackL16B}, {"L", "L;16B", 16, unpackL16B},
/* greyscale w. alpha */ /* grayscale w. alpha */
{"LA", "LA", 16, unpackLA}, {"LA", "LA", 16, unpackLA},
{"LA", "LA;L", 16, unpackLAL}, {"LA", "LA;L", 16, unpackLAL},
/* greyscale w. alpha premultiplied */ /* grayscale w. alpha premultiplied */
{"La", "La", 16, unpackLA}, {"La", "La", 16, unpackLA},
/* palette */ /* palette */