summaryrefslogtreecommitdiff
path: root/posts/2020-01-14-Converting-between-PIL-NumPy
diff options
context:
space:
mode:
Diffstat (limited to 'posts/2020-01-14-Converting-between-PIL-NumPy')
-rw-r--r--posts/2020-01-14-Converting-between-PIL-NumPy/index.html12
1 files changed, 4 insertions, 8 deletions
diff --git a/posts/2020-01-14-Converting-between-PIL-NumPy/index.html b/posts/2020-01-14-Converting-between-PIL-NumPy/index.html
index 13d0379..13cd71d 100644
--- a/posts/2020-01-14-Converting-between-PIL-NumPy/index.html
+++ b/posts/2020-01-14-Converting-between-PIL-NumPy/index.html
@@ -7,13 +7,9 @@
<span class="c1"># Convert array to Image</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">PIL</span><span class="o">.</span><span class="n">Image</span><span class="o">.</span><span class="n">fromarray</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
-</div>
-
-</code></pre><h2>Saving an Image</h2><pre><code><div class="highlight"><span></span><span class="k">try</span><span class="p">:</span>
- <span class="n">img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">destination</span><span class="p">,</span> <span class="s2">&quot;JPEG&quot;</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="mi">80</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">progressive</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+</div></code></pre><h2>Saving an Image</h2><pre><code><div class="highlight"><span></span><span class="k">try</span><span class="p">:</span>
+ <span class="n">img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">destination</span><span class="p">,</span> <span class="s2">&quot;JPEG&quot;</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="mi">80</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">progressive</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span>
<span class="n">PIL</span><span class="o">.</span><span class="n">ImageFile</span><span class="o">.</span><span class="n">MAXBLOCK</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">size</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">img</span><span class="o">.</span><span class="n">size</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
- <span class="n">img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">destination</span><span class="p">,</span> <span class="s2">&quot;JPEG&quot;</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="mi">80</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">progressive</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
-</div>
-
-</code></pre></div><span>Tagged with: </span><ul class="tag-list"><li><a href="/tags/codesnippet">code-snippet</a></li><li><a href="/tags/tutorial">tutorial</a></li></ul><div id="disqus_thread"></div><script src="/assets/disqus.js"></script><noscript>Please enable JavaScript to view the comments</noscript></article></div><footer><p>Made with ❤️ using <a href="https://github.com/johnsundell/publish">Publish</a></p><p><a href="/feed.rss">RSS feed</a></p></footer></body></html> \ No newline at end of file
+ <span class="n">img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">destination</span><span class="p">,</span> <span class="s2">&quot;JPEG&quot;</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="mi">80</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">progressive</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
+</div></code></pre></div><span>Tagged with: </span><ul class="tag-list"><li><a href="/tags/codesnippet">code-snippet</a></li><li><a href="/tags/tutorial">tutorial</a></li></ul><div id="disqus_thread"></div><script src="/assets/disqus.js"></script><noscript>Please enable JavaScript to view the comments</noscript></article></div><footer><p>Made with ❤️ using <a href="https://github.com/johnsundell/publish">Publish</a></p><p><a href="/feed.rss">RSS feed</a></p></footer></body></html> \ No newline at end of file