Skip to content

Commit fee7cf5

Browse files
committed
Image
1 parent 6e5a37a commit fee7cf5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,7 +2740,7 @@ Image
27402740
-----
27412741
```python
27422742
# $ pip3 install pillow
2743-
from PIL import Image
2743+
from PIL import Image, ImageDraw
27442744
```
27452745

27462746
```python
@@ -2764,6 +2764,8 @@ from PIL import Image
27642764
<3d_array> = np.array(<Image_RGB/A>) # Creates NumPy array from color image.
27652765
<Image> = Image.fromarray(np.uint8(<array>)) # Use <array>.clip(0, 255) to clip the values.
27662766
```
2767+
* **To edit an image use `'ImageEnhance'`, `'ImageFilter'` and `'ImageOps'` submodules.**
2768+
* **Custom filters can be applied to arrays using `'scipy.ndimage.convolve()'` function.**
27672769

27682770
### Modes
27692771
* **`'1'` - 1-bit pixels, black and white, stored with one pixel per byte.**
@@ -2794,11 +2796,7 @@ img.show()
27942796

27952797
### Image Draw
27962798
```python
2797-
from PIL import ImageDraw
2798-
<ImageDraw> = ImageDraw.Draw(<Image>)
2799-
```
2800-
2801-
```python
2799+
<ImageDraw> = ImageDraw.Draw(<Image>) # Object for adding 2D graphics to the image.
28022800
<ImageDraw>.point((x, y)) # Truncates floats into ints.
28032801
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize().
28042802
<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction.

index.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22402240

22412241

22422242
<div><h2 id="image"><a href="#image" name="image">#</a>Image</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install pillow</span>
2243-
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
2243+
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image, ImageDraw
22442244
</code></pre></div>
22452245

22462246
<pre><code class="python language-python hljs">&lt;Image&gt; = Image.new(<span class="hljs-string">'&lt;mode&gt;'</span>, (width, height)) <span class="hljs-comment"># Also: `color=&lt;int/tuple/str&gt;`.</span>
@@ -2259,6 +2259,10 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22592259
&lt;3d_array&gt; = np.array(&lt;Image_RGB/A&gt;) <span class="hljs-comment"># Creates NumPy array from color image.</span>
22602260
&lt;Image&gt; = Image.fromarray(np.uint8(&lt;array&gt;)) <span class="hljs-comment"># Use &lt;array&gt;.clip(0, 255) to clip the values.</span>
22612261
</code></pre>
2262+
<ul>
2263+
<li><strong>To edit an image use <code class="python hljs"><span class="hljs-string">'ImageEnhance'</span></code>, <code class="python hljs"><span class="hljs-string">'ImageFilter'</span></code> and <code class="python hljs"><span class="hljs-string">'ImageOps'</span></code> submodules.</strong></li>
2264+
<li><strong>Custom filters can be applied to arrays using <code class="python hljs"><span class="hljs-string">'scipy.ndimage.convolve()'</span></code> function.</strong></li>
2265+
</ul>
22622266
<div><h3 id="modes-1">Modes</h3><ul>
22632267
<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>
22642268
<li><strong><code class="python hljs"><span class="hljs-string">'L'</span></code> - 8-bit pixels, greyscale.</strong></li>
@@ -2283,17 +2287,15 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22832287
img.show()
22842288
</code></pre></div>
22852289

2286-
<div><h3 id="imagedraw">Image Draw</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> ImageDraw
2287-
&lt;ImageDraw&gt; = ImageDraw.Draw(&lt;Image&gt;)
2288-
</code></pre></div>
2289-
2290-
<pre><code class="python language-python hljs">&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Truncates floats into ints.</span>
2290+
<div><h3 id="imagedraw">Image Draw</h3><pre><code class="python language-python hljs">&lt;ImageDraw&gt; = ImageDraw.Draw(&lt;Image&gt;) <span class="hljs-comment"># Object for adding 2D graphics to the image.</span>
2291+
&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Truncates floats into ints.</span>
22912292
&lt;ImageDraw&gt;.line((x1, y1, x2, y2 [, ...])) <span class="hljs-comment"># To get anti-aliasing use Image's resize().</span>
22922293
&lt;ImageDraw&gt;.arc((x1, y1, x2, y2), deg1, deg2) <span class="hljs-comment"># Always draws in clockwise direction.</span>
22932294
&lt;ImageDraw&gt;.rectangle((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
22942295
&lt;ImageDraw&gt;.polygon((x1, y1, x2, y2, ...)) <span class="hljs-comment"># Last point gets connected to the first.</span>
22952296
&lt;ImageDraw&gt;.ellipse((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
2296-
</code></pre>
2297+
</code></pre></div>
2298+
22972299
<ul>
22982300
<li><strong>Use <code class="python hljs"><span class="hljs-string">'fill=&lt;color&gt;'</span></code> to set the primary color.</strong></li>
22992301
<li><strong>Use <code class="python hljs"><span class="hljs-string">'width=&lt;int&gt;'</span></code> to set the width of lines or contours.</strong></li>

0 commit comments

Comments
 (0)