Skip to content

Commit 594c8de

Browse files
committed
Image
1 parent c52d1b7 commit 594c8de

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,8 +2770,8 @@ from PIL import Image
27702770
```
27712771

27722772
```python
2773-
<Image> = Image.new('<mode>', (width, height)) # Also `color=<int/tuple/str>`.
2774-
<Image> = Image.open(<path>) # Identifies format based on file contents.
2773+
<Image> = Image.new('<mode>', (width, height)) # Creates new image. Also `color=<int/tuple>`.
2774+
<Image> = Image.open(<path>) # Identifies format based on file's contents.
27752775
<Image> = <Image>.convert('<mode>') # Converts image to the new mode.
27762776
<Image>.save(<path>) # Selects format based on the path extension.
27772777
<Image>.show() # Opens image in the default preview app.
@@ -2782,7 +2782,7 @@ from PIL import Image
27822782
<Image>.putpixel((x, y), <int/tuple>) # Updates pixel's value.
27832783
<ImagingCore> = <Image>.getdata() # Returns a flattened view of pixel values.
27842784
<Image>.putdata(<list/ImagingCore>) # Updates pixels with a copy of the sequence.
2785-
<Image>.paste(<Image>, (x, y)) # Draws passed image at specified location.
2785+
<Image>.paste(<Image>, (x, y)) # Draws passed image at the specified location.
27862786
```
27872787

27882788
```python
@@ -2796,10 +2796,10 @@ from PIL import Image
27962796
```
27972797

27982798
### Modes
2799-
* **`'L'` - 8-bit pixels, greyscale.**
2800-
* **`'RGB'` - 3x8-bit pixels, true color.**
2801-
* **`'RGBA'` - 4x8-bit pixels, true color with transparency mask.**
2802-
* **`'HSV'` - 3x8-bit pixels, Hue, Saturation, Value color space.**
2799+
* **`'L'` - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.**
2800+
* **`'RGB'` - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.**
2801+
* **`'RGBA'` - RGB with alpha. Low alpha (forth int) means more transparency.**
2802+
* **`'HSV'` - Hue, saturation, value color space.**
28032803

28042804
### Examples
28052805
#### Creates a PNG image of a rainbow gradient:

index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>May 18, 2024</aside>
57+
<aside>June 18, 2024</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -2262,8 +2262,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22622262
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
22632263
</code></pre></div>
22642264

2265-
<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>
2266-
&lt;Image&gt; = Image.open(&lt;path&gt;) <span class="hljs-comment"># Identifies format based on file contents.</span>
2265+
<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"># Creates new image. Also `color=&lt;int/tuple&gt;`.</span>
2266+
&lt;Image&gt; = Image.open(&lt;path&gt;) <span class="hljs-comment"># Identifies format based on file's contents.</span>
22672267
&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>
22682268
&lt;Image&gt;.save(&lt;path&gt;) <span class="hljs-comment"># Selects format based on the path extension.</span>
22692269
&lt;Image&gt;.show() <span class="hljs-comment"># Opens image in the default preview app.</span>
@@ -2272,7 +2272,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22722272
&lt;Image&gt;.putpixel((x, y), &lt;int/tuple&gt;) <span class="hljs-comment"># Updates pixel's value.</span>
22732273
&lt;ImagingCore&gt; = &lt;Image&gt;.getdata() <span class="hljs-comment"># Returns a flattened view of pixel values.</span>
22742274
&lt;Image&gt;.putdata(&lt;list/ImagingCore&gt;) <span class="hljs-comment"># Updates pixels with a copy of the sequence.</span>
2275-
&lt;Image&gt;.paste(&lt;Image&gt;, (x, y)) <span class="hljs-comment"># Draws passed image at specified location.</span>
2275+
&lt;Image&gt;.paste(&lt;Image&gt;, (x, y)) <span class="hljs-comment"># Draws passed image at the specified location.</span>
22762276
</code></pre>
22772277
<pre><code class="python language-python hljs">&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>
22782278
&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>
@@ -2281,10 +2281,10 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22812281
&lt;Image&gt; = Image.fromarray(np.uint8(&lt;array&gt;)) <span class="hljs-comment"># Use `&lt;array&gt;.clip(0, 255)` to clip values.</span>
22822282
</code></pre>
22832283
<div><h3 id="modes-1">Modes</h3><ul>
2284-
<li><strong><code class="python hljs"><span class="hljs-string">'L'</span></code> - 8-bit pixels, greyscale.</strong></li>
2285-
<li><strong><code class="python hljs"><span class="hljs-string">'RGB'</span></code> - 3x8-bit pixels, true color.</strong></li>
2286-
<li><strong><code class="python hljs"><span class="hljs-string">'RGBA'</span></code> - 4x8-bit pixels, true color with transparency mask.</strong></li>
2287-
<li><strong><code class="python hljs"><span class="hljs-string">'HSV'</span></code> - 3x8-bit pixels, Hue, Saturation, Value color space.</strong></li>
2284+
<li><strong><code class="python hljs"><span class="hljs-string">'L'</span></code> - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.</strong></li>
2285+
<li><strong><code class="python hljs"><span class="hljs-string">'RGB'</span></code> - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.</strong></li>
2286+
<li><strong><code class="python hljs"><span class="hljs-string">'RGBA'</span></code> - RGB with alpha. Low alpha (forth int) means more transparency.</strong></li>
2287+
<li><strong><code class="python hljs"><span class="hljs-string">'HSV'</span></code> - Hue, saturation, value color space.</strong></li>
22882288
</ul><div><h3 id="examples">Examples</h3><div><h4 id="createsapngimageofarainbowgradient">Creates a PNG image of a rainbow gradient:</h4><pre><code class="python language-python hljs">WIDTH, HEIGHT = <span class="hljs-number">100</span>, <span class="hljs-number">100</span>
22892289
n_pixels = WIDTH * HEIGHT
22902290
hues = (<span class="hljs-number">255</span> * i/n_pixels <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(n_pixels))
@@ -2932,7 +2932,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29322932

29332933

29342934
<footer>
2935-
<aside>May 18, 2024</aside>
2935+
<aside>June 18, 2024</aside>
29362936
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29372937
</footer>
29382938

0 commit comments

Comments
 (0)