From 594c8dec94509780d4bcd6e109fb06fbb7d15f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 18 Jun 2024 02:31:51 +0200 Subject: [PATCH] Image --- README.md | 14 +++++++------- index.html | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8828f1d..4c11b1e 100644 --- a/README.md +++ b/README.md @@ -2770,8 +2770,8 @@ from PIL import Image ``` ```python - = Image.new('', (width, height)) # Also `color=`. - = Image.open() # Identifies format based on file contents. + = Image.new('', (width, height)) # Creates new image. Also `color=`. + = Image.open() # Identifies format based on file's contents. = .convert('') # Converts image to the new mode. .save() # Selects format based on the path extension. .show() # Opens image in the default preview app. @@ -2782,7 +2782,7 @@ from PIL import Image .putpixel((x, y), ) # Updates pixel's value. = .getdata() # Returns a flattened view of pixel values. .putdata() # Updates pixels with a copy of the sequence. -.paste(, (x, y)) # Draws passed image at specified location. +.paste(, (x, y)) # Draws passed image at the specified location. ``` ```python @@ -2796,10 +2796,10 @@ from PIL import Image ``` ### Modes -* **`'L'` - 8-bit pixels, greyscale.** -* **`'RGB'` - 3x8-bit pixels, true color.** -* **`'RGBA'` - 4x8-bit pixels, true color with transparency mask.** -* **`'HSV'` - 3x8-bit pixels, Hue, Saturation, Value color space.** +* **`'L'` - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.** +* **`'RGB'` - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.** +* **`'RGBA'` - RGB with alpha. Low alpha (forth int) means more transparency.** +* **`'HSV'` - Hue, saturation, value color space.** ### Examples #### Creates a PNG image of a rainbow gradient: diff --git a/index.html b/index.html index 0909a38..667cad6 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2262,8 +2262,8 @@ right = [[0.1, 0.6from PIL import Image -
<Image> = Image.new('<mode>', (width, height))  # Also `color=<int/tuple/str>`.
-<Image> = Image.open(<path>)                    # Identifies format based on file contents.
+
<Image> = Image.new('<mode>', (width, height))  # Creates new image. Also `color=<int/tuple>`.
+<Image> = Image.open(<path>)                    # Identifies format based on file's contents.
 <Image> = <Image>.convert('<mode>')             # Converts image to the new mode.
 <Image>.save(<path>)                            # Selects format based on the path extension.
 <Image>.show()                                  # Opens image in the default preview app.
@@ -2272,7 +2272,7 @@ right = [[0.1,  0.6# Updates pixel's value.
 <ImagingCore> = <Image>.getdata()               # Returns a flattened view of pixel values.
 <Image>.putdata(<list/ImagingCore>)             # Updates pixels with a copy of the sequence.
-<Image>.paste(<Image>, (x, y))                  # Draws passed image at specified location.
+<Image>.paste(<Image>, (x, y))                  # Draws passed image at the specified location.
 
<Image> = <Image>.filter(<Filter>)              # `<Filter> = ImageFilter.<name>(<args>)`
 <Image> = <Enhance>.enhance(<float>)            # `<Enhance> = ImageEnhance.<name>(<Image>)`
@@ -2281,10 +2281,10 @@ right = [[0.1,  0.6# Use `<array>.clip(0, 255)` to clip values.
 

Modes

    -
  • 'L' - 8-bit pixels, greyscale.
  • -
  • 'RGB' - 3x8-bit pixels, true color.
  • -
  • 'RGBA' - 4x8-bit pixels, true color with transparency mask.
  • -
  • 'HSV' - 3x8-bit pixels, Hue, Saturation, Value color space.
  • +
  • 'L' - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.
  • +
  • 'RGB' - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.
  • +
  • 'RGBA' - RGB with alpha. Low alpha (forth int) means more transparency.
  • +
  • 'HSV' - Hue, saturation, value color space.

Examples

Creates a PNG image of a rainbow gradient:

WIDTH, HEIGHT = 100, 100
 n_pixels = WIDTH * HEIGHT
 hues = (255 * i/n_pixels for i in range(n_pixels))
@@ -2932,7 +2932,7 @@ $ deactivate                  # Deactivates the activ