Skip to content

Commit ef93860

Browse files
committed
Image
1 parent 50e35c4 commit ef93860

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,30 +2744,30 @@ from PIL import Image, ImageFilter, ImageEnhance, ImageDraw
27442744
```
27452745

27462746
```python
2747-
<Image> = Image.new('<mode>', (width, height)) # Also: `color=<int/tuple/str>`.
2748-
<Image> = Image.open(<path>) # Identifies format based on file contents.
2749-
<Image> = <Image>.convert('<mode>') # Converts image to the new mode.
2750-
<Image>.save(<path>) # Selects format based on the path extension.
2751-
<Image>.show() # Opens image in default preview app.
2747+
<Image> = Image.new('<mode>', (width, height)) # Also: `color=<int/tuple/str>`.
2748+
<Image> = Image.open(<path>) # Identifies format based on file contents.
2749+
<Image> = <Image>.convert('<mode>') # Converts image to the new mode.
2750+
<Image>.save(<path>) # Selects format based on the path extension.
2751+
<Image>.show() # Opens image in default preview app.
27522752
```
27532753

27542754
```python
2755-
<int/tuple> = <Image>.getpixel((x, y)) # Returns a pixel.
2756-
<Image>.putpixel((x, y), <int/tuple>) # Writes a pixel to the image.
2757-
<ImagingCore> = <Image>.getdata() # Returns a flattened sequence of pixels.
2758-
<Image>.putdata(<list/ImagingCore>) # Writes a flattened sequence of pixels.
2759-
<Image>.paste(<Image>, (x, y)) # Writes passed image to the image.
2755+
<int/tuple> = <Image>.getpixel((x, y)) # Returns a pixel.
2756+
<Image>.putpixel((x, y), <int/tuple>) # Writes a pixel to the image.
2757+
<ImagingCore> = <Image>.getdata() # Returns a flattened sequence of pixels.
2758+
<Image>.putdata(<list/ImagingCore>) # Writes a flattened sequence of pixels.
2759+
<Image>.paste(<Image>, (x, y)) # Writes passed image to the image.
27602760
```
27612761

27622762
```python
2763-
<Image> = <Image>.resize((width, height)) # Use <Image>.width/height for original sizes.
2764-
<Image> = <Image>.filter(<Filter>) # `<Filter> = ImageFilter.<name>([<args>])`
2765-
<Image> = <Enhance>.enhance(<float>) # `<Enhance> = ImageEnhance.<name>(<Image>)`
2763+
<Image> = <Image>.resize((width, height)) # Use <Image>.width/height for original sizes.
2764+
<Image> = <Image>.filter(<Filter>) # `<Filter> = ImageFilter.<name>([<args>])`
2765+
<Image> = <Enhance>.enhance(<float>) # `<Enhance> = ImageEnhance.<name>(<Image>)`
27662766
```
27672767

27682768
```python
2769-
<array> = np.array(<Image>) # Creates NumPy array from the image.
2770-
<Image> = Image.fromarray(np.uint8(<array>)) # Use <array>.clip(0, 255) to clip the values.
2769+
<array> = np.array(<Image>) # Creates NumPy array from the image.
2770+
<Image> = Image.fromarray(np.uint8(<array>)) # Use <array>.clip(0, 255) to clip the values.
27712771
```
27722772

27732773
### Modes
@@ -2799,13 +2799,13 @@ img.show()
27992799

28002800
### Image Draw
28012801
```python
2802-
<ImageDraw> = ImageDraw.Draw(<Image>) # Object for adding 2D graphics to the image.
2803-
<ImageDraw>.point((x, y)) # Draws a point. Truncates floats into ints.
2804-
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize().
2805-
<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction.
2806-
<ImageDraw>.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
2807-
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first.
2808-
<ImageDraw>.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
2802+
<ImageDraw> = ImageDraw.Draw(<Image>) # Object for adding 2D graphics to the image.
2803+
<ImageDraw>.point((x, y)) # Draws a point. Truncates floats into ints.
2804+
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize().
2805+
<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction.
2806+
<ImageDraw>.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
2807+
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first.
2808+
<ImageDraw>.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
28092809
```
28102810
* **Use `'fill=<color>'` to set the primary color.**
28112811
* **Use `'width=<int>'` to set the width of lines or contours.**

index.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,24 +2243,24 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22432243
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image, ImageFilter, ImageEnhance, ImageDraw
22442244
</code></pre></div>
22452245

2246-
<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>
2247-
&lt;Image&gt; = Image.open(&lt;path&gt;) <span class="hljs-comment"># Identifies format based on file contents.</span>
2248-
&lt;Image&gt; = &lt;Image&gt;.convert(<span class="hljs-string">'&lt;mode&gt;'</span>) <span class="hljs-comment"># Converts image to the new mode.</span>
2249-
&lt;Image&gt;.save(&lt;path&gt;) <span class="hljs-comment"># Selects format based on the path extension.</span>
2250-
&lt;Image&gt;.show() <span class="hljs-comment"># Opens image in default preview app.</span>
2246+
<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>
2247+
&lt;Image&gt; = Image.open(&lt;path&gt;) <span class="hljs-comment"># Identifies format based on file contents.</span>
2248+
&lt;Image&gt; = &lt;Image&gt;.convert(<span class="hljs-string">'&lt;mode&gt;'</span>) <span class="hljs-comment"># Converts image to the new mode.</span>
2249+
&lt;Image&gt;.save(&lt;path&gt;) <span class="hljs-comment"># Selects format based on the path extension.</span>
2250+
&lt;Image&gt;.show() <span class="hljs-comment"># Opens image in default preview app.</span>
22512251
</code></pre>
2252-
<pre><code class="python language-python hljs">&lt;int/tuple&gt; = &lt;Image&gt;.getpixel((x, y)) <span class="hljs-comment"># Returns a pixel.</span>
2253-
&lt;Image&gt;.putpixel((x, y), &lt;int/tuple&gt;) <span class="hljs-comment"># Writes a pixel to the image.</span>
2254-
&lt;ImagingCore&gt; = &lt;Image&gt;.getdata() <span class="hljs-comment"># Returns a flattened sequence of pixels.</span>
2255-
&lt;Image&gt;.putdata(&lt;list/ImagingCore&gt;) <span class="hljs-comment"># Writes a flattened sequence of pixels.</span>
2256-
&lt;Image&gt;.paste(&lt;Image&gt;, (x, y)) <span class="hljs-comment"># Writes passed image to the image.</span>
2252+
<pre><code class="python language-python hljs">&lt;int/tuple&gt; = &lt;Image&gt;.getpixel((x, y)) <span class="hljs-comment"># Returns a pixel.</span>
2253+
&lt;Image&gt;.putpixel((x, y), &lt;int/tuple&gt;) <span class="hljs-comment"># Writes a pixel to the image.</span>
2254+
&lt;ImagingCore&gt; = &lt;Image&gt;.getdata() <span class="hljs-comment"># Returns a flattened sequence of pixels.</span>
2255+
&lt;Image&gt;.putdata(&lt;list/ImagingCore&gt;) <span class="hljs-comment"># Writes a flattened sequence of pixels.</span>
2256+
&lt;Image&gt;.paste(&lt;Image&gt;, (x, y)) <span class="hljs-comment"># Writes passed image to the image.</span>
22572257
</code></pre>
2258-
<pre><code class="python language-python hljs">&lt;Image&gt; = &lt;Image&gt;.resize((width, height)) <span class="hljs-comment"># Use &lt;Image&gt;.width/height for original sizes.</span>
2259-
&lt;Image&gt; = &lt;Image&gt;.filter(&lt;Filter&gt;) <span class="hljs-comment"># `&lt;Filter&gt; = ImageFilter.&lt;name&gt;([&lt;args&gt;])`</span>
2260-
&lt;Image&gt; = &lt;Enhance&gt;.enhance(&lt;float&gt;) <span class="hljs-comment"># `&lt;Enhance&gt; = ImageEnhance.&lt;name&gt;(&lt;Image&gt;)`</span>
2258+
<pre><code class="python language-python hljs">&lt;Image&gt; = &lt;Image&gt;.resize((width, height)) <span class="hljs-comment"># Use &lt;Image&gt;.width/height for original sizes.</span>
2259+
&lt;Image&gt; = &lt;Image&gt;.filter(&lt;Filter&gt;) <span class="hljs-comment"># `&lt;Filter&gt; = ImageFilter.&lt;name&gt;([&lt;args&gt;])`</span>
2260+
&lt;Image&gt; = &lt;Enhance&gt;.enhance(&lt;float&gt;) <span class="hljs-comment"># `&lt;Enhance&gt; = ImageEnhance.&lt;name&gt;(&lt;Image&gt;)`</span>
22612261
</code></pre>
2262-
<pre><code class="python language-python hljs">&lt;array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Creates NumPy array from the image.</span>
2263-
&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>
2262+
<pre><code class="python language-python hljs">&lt;array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Creates NumPy array from the image.</span>
2263+
&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>
22642264
</code></pre>
22652265
<div><h3 id="modes-1">Modes</h3><ul>
22662266
<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>
@@ -2286,13 +2286,13 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22862286
img.show()
22872287
</code></pre></div>
22882288

2289-
<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>
2290-
&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Draws a point. Truncates floats into ints.</span>
2291-
&lt;ImageDraw&gt;.line((x1, y1, x2, y2 [, ...])) <span class="hljs-comment"># To get anti-aliasing use Image's resize().</span>
2292-
&lt;ImageDraw&gt;.arc((x1, y1, x2, y2), deg1, deg2) <span class="hljs-comment"># Always draws in clockwise direction.</span>
2293-
&lt;ImageDraw&gt;.rectangle((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
2294-
&lt;ImageDraw&gt;.polygon((x1, y1, x2, y2, ...)) <span class="hljs-comment"># Last point gets connected to the first.</span>
2295-
&lt;ImageDraw&gt;.ellipse((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
2289+
<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>
2290+
&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Draws a point. Truncates floats into ints.</span>
2291+
&lt;ImageDraw&gt;.line((x1, y1, x2, y2 [, ...])) <span class="hljs-comment"># To get anti-aliasing use Image's resize().</span>
2292+
&lt;ImageDraw&gt;.arc((x1, y1, x2, y2), deg1, deg2) <span class="hljs-comment"># Always draws in clockwise direction.</span>
2293+
&lt;ImageDraw&gt;.rectangle((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
2294+
&lt;ImageDraw&gt;.polygon((x1, y1, x2, y2, ...)) <span class="hljs-comment"># Last point gets connected to the first.</span>
2295+
&lt;ImageDraw&gt;.ellipse((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
22962296
</code></pre></div>
22972297

22982298
<ul>

0 commit comments

Comments
 (0)