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/<image>') 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 <Image>.paste(<Image>, (x, y)) # Writes an image to image. ``` +```bash +<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.** diff --git a/index.html b/index.html index 35b8639..66efced 100644 --- a/index.html +++ b/index.html @@ -2073,7 +2073,7 @@ run(host=<span class="hljs-string">'0.0.0.0'</span>, port=<span class="hljs-numb <div><h3 id="staticrequest">Static Request</h3><pre><code class="python language-python hljs"><span class="hljs-meta">@route('/img/<image>')</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">send_image</span><span class="hljs-params">(image)</span>:</span> - <span class="hljs-keyword">return</span> static_file(image, <span class="hljs-string">'images/'</span>, mimetype=<span class="hljs-string">'image/png'</span>) + <span class="hljs-keyword">return</span> static_file(image, <span class="hljs-string">'img_dir/'</span>, mimetype=<span class="hljs-string">'image/png'</span>) </code></pre></div> <div><h3 id="dynamicrequest">Dynamic Request</h3><pre><code class="python language-python hljs"><span class="hljs-meta">@route('/<sport>')</span> @@ -2244,6 +2244,10 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</s <Image>.putdata(<list/ImagingCore>) <span class="hljs-comment"># Writes a sequence of pixels.</span> <Image>.paste(<Image>, (x, y)) <span class="hljs-comment"># Writes an image to image.</span> </code></pre> +<pre><code class="bash language-bash hljs"><2d_array> = np.array(<Image>) <span class="hljs-comment"># NumPy array from greyscale image.</span> +<3d_array> = np.array(<Image>) <span class="hljs-comment"># NumPy array from color image.</span> +<Image> = Image.fromarray(<array>) <span class="hljs-comment"># Image from NumPy array.</span> +</code></pre> <div><h3 id="modes-1">Modes</h3><ul> <li><strong><code class="python hljs"><span class="hljs-string">'1'</span></code> - 1-bit pixels, black and white, stored with one pixel per byte.</strong></li> <li><strong><code class="python hljs"><span class="hljs-string">'L'</span></code> - 8-bit pixels, greyscale.</strong></li>