From 50e35c4c9774ad5f901fa6d8a2511b09b75c7e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 2 Feb 2023 14:32:22 +0100 Subject: [PATCH] Image --- README.md | 19 +++++++++++-------- index.html | 21 ++++++++++----------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 25c6e26..3948fb3 100644 --- a/README.md +++ b/README.md @@ -2740,7 +2740,7 @@ Image ----- ```python # $ pip3 install pillow -from PIL import Image, ImageDraw +from PIL import Image, ImageFilter, ImageEnhance, ImageDraw ``` ```python @@ -2759,13 +2759,16 @@ from PIL import Image, ImageDraw .paste(, (x, y)) # Writes passed image to the image. ``` -```bash -<2d_array> = np.array() # Creates NumPy array from greyscale image. -<3d_array> = np.array() # Creates NumPy array from color image. - = Image.fromarray(np.uint8()) # Use .clip(0, 255) to clip the values. +```python + = .resize((width, height)) # Use .width/height for original sizes. + = .filter() # ` = ImageFilter.([])` + = .enhance() # ` = ImageEnhance.()` +``` + +```python + = np.array() # Creates NumPy array from the image. + = Image.fromarray(np.uint8()) # Use .clip(0, 255) to clip the values. ``` -* **To edit an image use `'ImageEnhance'`, `'ImageFilter'` and `'ImageOps'` submodules.** -* **Custom filters can be applied to arrays using `'scipy.ndimage.convolve()'` function.** ### Modes * **`'1'` - 1-bit pixels, black and white, stored with one pixel per byte.** @@ -2797,7 +2800,7 @@ img.show() ### Image Draw ```python = ImageDraw.Draw() # Object for adding 2D graphics to the image. -.point((x, y)) # Truncates floats into ints. +.point((x, y)) # Draws a point. Truncates floats into ints. .line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize(). .arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. .rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste(). diff --git a/index.html b/index.html index 1045942..ea9a4bf 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2240,7 +2240,7 @@ right = [[0.1, 0.6

#Image

# $ pip3 install pillow
-from PIL import Image, ImageDraw
+from PIL import Image, ImageFilter, ImageEnhance, ImageDraw
 
<Image> = Image.new('<mode>', (width, height))   # Also: `color=<int/tuple/str>`.
@@ -2255,14 +2255,13 @@ right = [[0.1,  0.6# Writes a flattened sequence of pixels.
 <Image>.paste(<Image>, (x, y))                   # Writes passed image to the image.
 
-
<2d_array> = np.array(<Image_L>)                 # Creates NumPy array from greyscale image.
-<3d_array> = np.array(<Image_RGB/A>)             # Creates NumPy array from color image.
-<Image>    = Image.fromarray(np.uint8(<array>))  # Use <array>.clip(0, 255) to clip the values.
+
<Image> = <Image>.resize((width, height))        # Use <Image>.width/height for original sizes.
+<Image> = <Image>.filter(<Filter>)               # `<Filter> = ImageFilter.<name>([<args>])`
+<Image> = <Enhance>.enhance(<float>)             # `<Enhance> = ImageEnhance.<name>(<Image>)`
+
+
<array> = np.array(<Image>)                      # Creates NumPy array from the image.
+<Image> = Image.fromarray(np.uint8(<array>))     # Use <array>.clip(0, 255) to clip the values.
 
-
    -
  • To edit an image use 'ImageEnhance', 'ImageFilter' and 'ImageOps' submodules.
  • -
  • Custom filters can be applied to arrays using 'scipy.ndimage.convolve()' function.
  • -

Modes

  • '1' - 1-bit pixels, black and white, stored with one pixel per byte.
  • 'L' - 8-bit pixels, greyscale.
  • @@ -2288,7 +2287,7 @@ img.show()

Image Draw

<ImageDraw> = ImageDraw.Draw(<Image>)            # Object for adding 2D graphics to the image.
-<ImageDraw>.point((x, y))                        # Truncates floats into ints.
+<ImageDraw>.point((x, y))                        # Draws a point. Truncates floats into ints.
 <ImageDraw>.line((x1, y1, x2, y2 [, ...]))       # To get anti-aliasing use Image's resize().
 <ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2)    # Always draws in clockwise direction.
 <ImageDraw>.rectangle((x1, y1, x2, y2))          # To rotate use Image's rotate() and paste().
@@ -2924,7 +2923,7 @@ $ pyinstaller script.py --add-data '<path>:.'