From 45efec6bf86b96c9c68f81f85bc259991d045919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 3 Oct 2019 21:22:18 +0200 Subject: [PATCH] Image --- README.md | 8 +++++++- index.html | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c656995..8e2005b 100644 --- a/README.md +++ b/README.md @@ -2410,7 +2410,7 @@ run(host='0.0.0.0', port=80, server='cherrypy') ```python @route('/img/') def send_image(image): - return static_file(image, 'images/', mimetype='image/png') + return static_file(image, 'img_dir/', mimetype='image/png') ``` ### Dynamic Request @@ -2638,6 +2638,12 @@ from PIL import Image .paste(, (x, y)) # Writes an image to image. ``` +```bash +<2d_array> = np.array() # NumPy array from greyscale image. +<3d_array> = np.array() # NumPy array from color image. + = Image.fromarray() # Image from NumPy array. +``` + ### Modes * **`'1'` - 1-bit pixels, black and white, stored with one pixel per byte.** * **`'L'` - 8-bit pixels, greyscale.** diff --git a/index.html b/index.html index 35b8639..66efced 100644 --- a/index.html +++ b/index.html @@ -2073,7 +2073,7 @@ run(host='0.0.0.0', port=Static Request
@route('/img/<image>')
 def send_image(image):
-    return static_file(image, 'images/', mimetype='image/png')
+    return static_file(image, 'img_dir/', mimetype='image/png')
 

Dynamic Request

@route('/<sport>')
@@ -2244,6 +2244,10 @@ right = [[0.1, 0.6# Writes a sequence of pixels.
 <Image>.paste(<Image>, (x, y))                  # Writes an image to image.
 
+
<2d_array> = np.array(<Image>)                  # NumPy array from greyscale image.
+<3d_array> = np.array(<Image>)                  # NumPy array from color image.
+<Image>    = Image.fromarray(<array>)           # Image from NumPy array.
+

Modes

  • '1' - 1-bit pixels, black and white, stored with one pixel per byte.
  • 'L' - 8-bit pixels, greyscale.