<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Nodejs on foosel.net</title><link>https://foosel.net/tags/nodejs/</link><description>Recent content in Nodejs on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Mon, 06 Feb 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/nodejs/feed.xml" rel="self" type="application/rss+xml"/><item><title>How to quickly generate a QR Code with transparent background</title><link>https://foosel.net/til/how-to-quickly-generate-a-qr-code-with-transparent-background/</link><pubDate>Mon, 06 Feb 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/how-to-quickly-generate-a-qr-code-with-transparent-background/</guid><description>&lt;p&gt;For an upcoming presentation I wanted to quickly generate a QR Code of my web site&amp;rsquo;s URL to include on the final slide. Since my slide theme has a green gradient background with white text, I wanted the QR Code to be white on a transparent background, as a PNG.&lt;/p&gt;
&lt;p&gt;Enter &lt;a href="https://github.com/soldair/node-qrcode"&gt;node-qrcode&lt;/a&gt; which runs easily via &lt;code&gt;npx&lt;/code&gt;&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npx qrcode -o output.png -d FFFF -l &lt;span style="color:#ae81ff"&gt;0000&lt;/span&gt; -w &lt;span style="color:#ae81ff"&gt;500&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;https://foosel.net&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-o output.png&lt;/code&gt; sets the output file&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-d FFFF&lt;/code&gt; sets the dark color (usually black) to white with 100% opacity&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-l 0000&lt;/code&gt; sets the light color (usually white) to black with 0% opacity - fully transparent&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-w 500&lt;/code&gt; sets the size to 500px&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For further options like error correction or QR code version, or how to use it as a library or in the browser, see node-qrcode&amp;rsquo;s repo linked above.&lt;/p&gt;</description><content:encoded><![CDATA[<p>For an upcoming presentation I wanted to quickly generate a QR Code of my web site&rsquo;s URL to include on the final slide. Since my slide theme has a green gradient background with white text, I wanted the QR Code to be white on a transparent background, as a PNG.</p>
<p>Enter <a href="https://github.com/soldair/node-qrcode">node-qrcode</a> which runs easily via <code>npx</code><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>npx qrcode -o output.png -d FFFF -l <span style="color:#ae81ff">0000</span> -w <span style="color:#ae81ff">500</span>  <span style="color:#e6db74">&#34;https://foosel.net&#34;</span>
</span></span></code></pre></div><ul>
<li><code>-o output.png</code> sets the output file</li>
<li><code>-d FFFF</code> sets the dark color (usually black) to white with 100% opacity</li>
<li><code>-l 0000</code> sets the light color (usually white) to black with 0% opacity - fully transparent</li>
<li><code>-w 500</code> sets the size to 500px</li>
</ul>
<p>For further options like error correction or QR code version, or how to use it as a library or in the browser, see node-qrcode&rsquo;s repo linked above.</p>
<p>I for one am happy with the result of this little exercise:</p>
<p><img alt="The final slide of a presentation. It says &ldquo;Thank you for you attention!&rdquo;. Below that I&rsquo;ve listed my Mastodon account @foosel@chaos.social, my GitHub account @foosel and my website&rsquo;s address foosel.net. A big white QR Code is placed right underneath, a handdrawn arrow points from website to code." loading="lazy" src="/til/how-to-quickly-generate-a-qr-code-with-transparent-background/slide.png"></p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>Yes, there are also online services that can do this for you, no, I didn&rsquo;t want to look through dozens of them trying to find one that didn&rsquo;t attempt to make me subscribe to something just to change the color of the generated QR code. Local CLI ftw.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>