summaryrefslogtreecommitdiff
path: root/posts/2020-01-14-Converting-between-PIL-NumPy
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-06-01 12:33:18 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-06-01 12:33:18 +0530
commit3ec7d22d1ca0c5a5bbd54a735f917aebab633928 (patch)
treefb0b17a87eb4e41bb5aa7fec173a173724dfefa3 /posts/2020-01-14-Converting-between-PIL-NumPy
parent20b1941b672cb133ff4ca4c5cb45ae70cdd8c5f7 (diff)
Publish deploy 2020-06-01 12:33
Diffstat (limited to 'posts/2020-01-14-Converting-between-PIL-NumPy')
-rw-r--r--posts/2020-01-14-Converting-between-PIL-NumPy/index.html4
1 files changed, 2 insertions, 2 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 13cd71d..8d0fe0a 100644
--- a/posts/2020-01-14-Converting-between-PIL-NumPy/index.html
+++ b/posts/2020-01-14-Converting-between-PIL-NumPy/index.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><title>Converting between image and NumPy array | Navan Chauhan</title><meta name="twitter:title" content="Converting between image and NumPy array | Navan Chauhan"/><meta name="og:title" content="Converting between image and NumPy array | Navan Chauhan"/><meta name="description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="twitter:description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="og:description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script src="https://www.googletagmanager.com/gtag/js?id=UA-108635191-1v"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-108635191-1');</script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">1 minute read</span><span class="reading-time">Created on January 14, 2020</span><span class="reading-time">Last modified on March 9, 2020</span><h1>Converting between image and NumPy array</h1><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">numpy</span>
+<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2020-01-14-Converting-between-PIL-NumPy"/><title>Converting between image and NumPy array | Navan Chauhan</title><meta name="twitter:title" content="Converting between image and NumPy array | Navan Chauhan"/><meta name="og:title" content="Converting between image and NumPy array | Navan Chauhan"/><meta name="description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="twitter:description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="og:description" content="Short code snippet for converting between PIL image and NumPy arrays."/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script src="https://www.googletagmanager.com/gtag/js?id=UA-108635191-1v"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-108635191-1');</script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">1 minute read</span><span class="reading-time">Created on January 14, 2020</span><span class="reading-time">Last modified on June 1, 2020</span><h1>Converting between image and NumPy array</h1><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">numpy</span>
<span class="kn">import</span> <span class="nn">PIL</span>
<span class="c1"># Convert PIL Image to NumPy array</span>
@@ -12,4 +12,4 @@
<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="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
+</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