<pre><codeclass="python language-python hljs"><tuple/int> = img.getpixel((x, y)) <spanclass="hljs-comment"># Returns a pixel.</span>
<Image>.putpixel((x, y), <tuple/int>) <spanclass="hljs-comment"># Writes tuple/int to image.</span>
<ImagingCore> = <Image>.getdata() <spanclass="hljs-comment"># Returns a sequence of tuples/ints.</span>
<Image>.putdata(<list/tuple>) <spanclass="hljs-comment"># Writes a sequence of tuples/ints.</span>
<Image>.paste(<Image>, (x, y)) <spanclass="hljs-comment"># Writes an image to image.</span>
<pre><codeclass="python language-python hljs"><tuple/int> = img.getpixel((x, y)) <spanclass="hljs-comment"># Returns a pixel.</span>
<Image>.putpixel((x, y), <tuple/int>) <spanclass="hljs-comment"># Writes a pixel to image.</span>
<ImagingCore> = <Image>.getdata() <spanclass="hljs-comment"># Returns a sequence of pixels.</span>
<Image>.putdata(<list/tuple>) <spanclass="hljs-comment"># Writes a sequence of pixels.</span>
<Image>.paste(<Image>, (x, y)) <spanclass="hljs-comment"># Writes an image to image.</span>
</code></pre>
</code></pre>
<div><h3id="modes-1">Modes</h3><ul>
<div><h3id="modes-1">Modes</h3><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'1'</span></code> - 1-bit pixels, black and white, stored with one pixel per byte.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'1'</span></code> - 1-bit pixels, black and white, stored with one pixel per byte.</strong></li>
@ -2201,30 +2201,15 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</s
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'fill=<color>'</span></code> to set the primary color.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'outline=<color>'</span></code> to set the secondary color.</strong></li>
<li><strong>Colors can be specified as tuple, int, <codeclass="python hljs"><spanclass="hljs-string">'#rrggbb'</span></code> string or a color name.</strong></li>
</ul>
<div><h3id="examples">Examples</h3><div><h4id="createsapngimageofarainbowgradient">Creates a PNG image of a rainbow gradient:</h4><pre><codeclass="python language-python hljs">WIDTH, HEIGHT = <spanclass="hljs-number">100</span>, <spanclass="hljs-number">100</span>
</ul><div><h3id="examples">Examples</h3><div><h4id="createsapngimageofarainbowgradient">Creates a PNG image of a rainbow gradient:</h4><pre><codeclass="python language-python hljs">WIDTH, HEIGHT = <spanclass="hljs-number">100</span>, <spanclass="hljs-number">100</span>
size = WIDTH * HEIGHT
size = WIDTH * HEIGHT
hue = [<spanclass="hljs-number">255</span> * i/size <spanclass="hljs-keyword">for</span> i <spanclass="hljs-keyword">in</span> range(size)]
hue = [<spanclass="hljs-number">255</span> * i/size <spanclass="hljs-keyword">for</span> i <spanclass="hljs-keyword">in</span> range(size)]
<div><h4id="addsnoisetoapngimage">Adds noise to a PNG image:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> random <spanclass="hljs-keyword">import</span> randint
<div><h4id="addsnoisetoapngimage">Adds noise to a PNG image:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> random <spanclass="hljs-keyword">import</span> randint
<div><h2id="animation"><ahref="#animation"name="animation">#</a>Animation</h2><div><h4id="createsagifofabouncingball">Creates a GIF of a bouncing ball:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-comment"># $ pip3 install imageio</span>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'fill=<color>'</span></code> to set the primary color.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'outline=<color>'</span></code> to set the secondary color.</strong></li>
<li><strong>Colors can be specified as tuple, int, <codeclass="python hljs"><spanclass="hljs-string">'#rrggbb'</span></code> string or a color name.</strong></li>
</ul>
<div><h2id="animation"><ahref="#animation"name="animation">#</a>Animation</h2><div><h4id="createsagifofabouncingball">Creates a GIF of a bouncing ball:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-comment"># $ pip3 install pillow imageio</span>