blog fix date: Resizing 2500 photos

This commit is contained in:
murtezayesil 2020-08-13 15:37:27 +06:00
parent ccc47fb6d9
commit 641a413c9e
14 changed files with 761 additions and 475 deletions

View File

@ -1,9 +1,9 @@
title: Resizing 2500 photos
date: 2020-07-13 07:19
date: 2020-08-13 07:19
tags: code, 100DaysToOffload
summary: We needed to resize 2500 photographs for a website. There is a shell script for that.
status: published
comment:
comment: https://fosstodon.org/@murtezayesil/104681372709677657
hundreddaystooffload: 18
I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used [imagemagick](https://imagemagick.org/) to write [desktop-clock](https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock "use imagemagick, figlet and feh for tty-clock on wallpaper"), immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.

View File

@ -51,6 +51,8 @@
<h1>Archives for Ali Murteza Yesil</h1>
<dl>
<dt>Thu 13 August 2020</dt>
<dd><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></dd>
<dt>Tue 11 August 2020</dt>
<dd><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html">Switching to Bluetooth earphones</a></dd>
<dt>Sun 09 August 2020</dt>
@ -81,8 +83,6 @@
<dd><a href="https://murtezayesil.me/digital-cleansing-nextcloud.html">Digital Cleansing - NextCloud</a></dd>
<dt>Tue 14 July 2020</dt>
<dd><a href="https://murtezayesil.me/digital-cleansing-identifying-services-we-use.html">Digital Cleansing - Identifying services we use</a></dd>
<dt>Mon 13 July 2020</dt>
<dd><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></dd>
<dt>Sun 12 July 2020</dt>
<dd><a href="https://murtezayesil.me/digital-cleansing-for-better-privacy.html">Digital Cleansing For Better Privacy</a></dd>
<dt>Fri 10 July 2020</dt>

View File

@ -50,32 +50,122 @@
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html">Switching to Bluetooth earphones</a></h1>
<h1 class="entry-title"><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></h1>
<footer class="post-info">
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used <a href="https://imagemagick.org/">imagemagick</a> to write <a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper">desktop-clock</a>, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.</p>
<div class="highlight"><pre><span></span><code>/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾<span class="se">\ </span>
<span class="p">|</span> <span class="k">for</span> each image <span class="p">|</span>
<span class="p">|</span> <span class="k">do</span> resize to <span class="nv">height</span><span class="o">=</span><span class="m">800</span> <span class="p">|</span>
<span class="se">\_</span>__________________________/
O
o <span class="se">\_\_</span> _/_/
. <span class="se">\_</span>_/
<span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="o">(</span>__<span class="o">)</span><span class="se">\ </span> <span class="o">)</span><span class="se">\/\</span>
<span class="o">||</span>----w <span class="p">|</span>
<span class="o">||</span> <span class="o">||</span>
</code></pre></div>
<h1>This is a learning opportunity</h1>
<p>Since I don't have much of an experience on shell scripting, I was <a href="https://start.duckduckgo.com/" title="DuckDuckGo">Duck</a>ing everything. I learned to do few things during this task.</p>
<ol>
<li><a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials">For loops in shell script</a></li>
<li>Getting <a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️">list of files</a></li>
<li>Correct syntax for <a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️">resizing with ImageMagick</a></li>
</ol>
<p>After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. </p>
<p>Here is <code>image_shrinker.v0.1_alpha.sh</code> :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale 1000000x800 ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This version has problems which I can't call "feature" 😁️ :</p>
<ol>
<li>Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.</li>
<li>Script must be in same directory as images</li>
<li>PWD must point to the directory where script is</li>
</ol>
<h2>Adjustable resolution</h2>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$WIDTHx$HEIGHT</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$#</span> -lt <span class="m">2</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="s2">&quot;USAGE:&quot;</span>
<span class="nb">echo</span> -e <span class="s2">&quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&quot;</span>
<span class="nb">exit</span> <span class="m">1</span>
<span class="k">fi</span>
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
mkdir ../output
<span class="k">for</span> image in *
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$Resolution</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">DIR</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
<span class="k">for</span> image in ./*.*
<span class="k">do</span>
<span class="c1"># Below code will scale images to 800px height without breaking aspect ratio</span>
convert <span class="nv">$DIR</span>/<span class="nv">$image</span> -scale 10000x800 -write <span class="nv">$DIR</span>/../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html" rel="bookmark"
title="Permalink to Switching to Bluetooth earphones">Switching to Bluetooth earphones</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Tue 11 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/personal.html">Personal</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>17</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>My one and only phone, Andromeda, is a Redmi Note 4. I purchased it 3 years ago. It initially suffered from problems such as consuming battery for self overheating. But I later switched custom ROMs, Lineage and Havoc OS, and battery started to last more than a day. Andromeda served me well in its 3 years of service and it continues to do so albeit with some hickups.</p>
<p>I am not the best phone user. I actually am a clumsy person who drops his phone on regular basis. So much so that Andromeda's display got replaced once and glass twice. Its glass is broken as I write these lines 😁️</p>
<p>But broken glass isn't the issue. It still detects my touches fairly accurately. Real problem is that, a recent drop resulted <strong>front speaker to stop working</strong> so that I can't hear other person during phone calls and some copper piece come out of headphone jack which rendered <strong>microphone on headsets to not connect</strong> so that other person cannot hear me during a phone call (if I am using a headphone). My temporary solution was to use loud speaker which is annoying and makes private calls difficult. Also it is rude in public. Another option was bluetooth speaker which requires some budget.</p>
<p>I could spare 20$ for a pair bluetooth earphones. Pretty generous huh 😜️<br>
Anyway, after some market search I set my mind on Redmi Airdots.</p>
<p><strong>Do I recommend them?</strong><br>
No and Yes. They aren't the best earphones, not even best in-ear earphones, but they are affordable.<br>
Just like every other in-ear earphones, they aren't comfortable even after I replaced the tips with different size that better fits 😕️ They will do for now. It isn't too much of a deal since I am planning to use them only for calls. Speakers on wired earphones still work with the phone fortunately.</p>
<div style="text-align: center;">
<img src="images/memes/modern_problems_bluetooth_earphones.jpg" alt="Top Caption: Switched to Bluetooth earphones after phone's headphone jack. Bottom Caption: Modern problems require modern solutions">
</div><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104672484458036109">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
@ -202,22 +292,6 @@ Just like every other in-ear earphones, they aren't comfortable even after I rep
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>9</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
</ol><!-- /#posts-list -->

View File

@ -50,6 +50,22 @@
<section id="content" class="body">
<ol id="posts-list" class="hfeed" start="9">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/adb_vendor_keys-is-not-set.html" rel="bookmark"
@ -127,22 +143,6 @@
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100daystooffload</a></span> <span>| Day <strong>3</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/resizing-2500-photos.html" rel="bookmark"
title="Permalink to Resizing 2500 photos">Resizing 2500 photos</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>

View File

@ -50,103 +50,122 @@
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="https://murtezayesil.me/digital-cleansing-music.html">Digital Cleansing - Music</a></h1>
<h1 class="entry-title"><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></h1>
<footer class="post-info">
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used <a href="https://imagemagick.org/">imagemagick</a> to write <a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper">desktop-clock</a>, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.</p>
<div class="highlight"><pre><span></span><code>/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾<span class="se">\ </span>
<span class="p">|</span> <span class="k">for</span> each image <span class="p">|</span>
<span class="p">|</span> <span class="k">do</span> resize to <span class="nv">height</span><span class="o">=</span><span class="m">800</span> <span class="p">|</span>
<span class="se">\_</span>__________________________/
O
o <span class="se">\_\_</span> _/_/
. <span class="se">\_</span>_/
<span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="o">(</span>__<span class="o">)</span><span class="se">\ </span> <span class="o">)</span><span class="se">\/\</span>
<span class="o">||</span>----w <span class="p">|</span>
<span class="o">||</span> <span class="o">||</span>
</code></pre></div>
<h1>This is a learning opportunity</h1>
<p>Since I don't have much of an experience on shell scripting, I was <a href="https://start.duckduckgo.com/" title="DuckDuckGo">Duck</a>ing everything. I learned to do few things during this task.</p>
<ol>
<li><a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials">For loops in shell script</a></li>
<li>Getting <a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️">list of files</a></li>
<li>Correct syntax for <a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️">resizing with ImageMagick</a></li>
</ol>
<p>After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. </p>
<p>Here is <code>image_shrinker.v0.1_alpha.sh</code> :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale 1000000x800 ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This version has problems which I can't call "feature" 😁️ :</p>
<ol>
<li>Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.</li>
<li>Script must be in same directory as images</li>
<li>PWD must point to the directory where script is</li>
</ol>
<h2>Adjustable resolution</h2>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$WIDTHx$HEIGHT</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$#</span> -lt <span class="m">2</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="s2">&quot;USAGE:&quot;</span>
<span class="nb">echo</span> -e <span class="s2">&quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&quot;</span>
<span class="nb">exit</span> <span class="m">1</span>
<span class="k">fi</span>
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
mkdir ../output
<span class="k">for</span> image in *
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$Resolution</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">DIR</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
<span class="k">for</span> image in ./*.*
<span class="k">do</span>
<span class="c1"># Below code will scale images to 800px height without breaking aspect ratio</span>
convert <span class="nv">$DIR</span>/<span class="nv">$image</span> -scale 10000x800 -write <span class="nv">$DIR</span>/../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-music.html" rel="bookmark"
title="Permalink to Digital Cleansing - Music">Digital Cleansing - Music</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 03 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/music.html">music</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>13</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>I like listening to musics and I am not the only one. Just look at how many people are listening to <a href="https://www.youtube.com/watch?v=5qap5aO4i9A" title="lofi hip hop radio - beats to relax/study to on YouTube">LoFi music with the study girl</a> or look how many views <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">this song</a> has. As a young adult, I remember the times the CDs were the king of music distribution. But they are long gone. Thanks to internet, digital music stores and music streaming services replaced CDs.<br>
So here I am, looking for the best music listening solution I can get. After a little search on the internet I came up with the below list of music stores or streaming services.</p>
<table>
<thead>
<tr>
<th>Online Music Stores</th>
<th>Music Streaming Services</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://www.apple.com/itunes/" title="DRM">iTunes</a></td>
<td><a href="https://music.apple.com/" title="DRM">Apple Music</a></td>
</tr>
<tr>
<td><a href="https://bandcamp.com/">BandCamp</a></td>
<td><a href="https://bandcamp.com/">BandCamp</a></td>
</tr>
<tr>
<td><a href="https://amazon.com" title="DRM">Amazon Store</a></td>
<td><a href="https://music.amazon.com/" title="DRM">Amazon Music</a></td>
</tr>
<tr>
<td><a href="https://www.emusic.com/" title="Limited selection but may use">eMusic</a></td>
<td><a href="https://www.spotify.com/" title="Not available">Spotify</a></td>
</tr>
<tr>
<td><a href="https://bleep.com/" title="limited selection">Bleep</a></td>
<td><a href="https://us.napster.com/" title="DRM">Napster</a></td>
</tr>
<tr>
<td><a href="https://killedbygoogle.com/" title="Killed By Google - December 2020">Google Play Music</a></td>
<td><a href="https://music.youtube.com/" title="Not available">YouTube Music</a></td>
</tr>
<tr>
<td><a href="https://www.jamendo.com/">Jamendo</a></td>
<td><a href="https://www.jamendo.com/">Jamendo</a></td>
</tr>
<tr>
<td><a href="https://www.beatport.com/" title="not my jazz">BeatPort</a></td>
<td><a href="https://tidal.com/" title="DRM">Tidal</a></td>
</tr>
</tbody>
</table>
<p>There are many options and above isn't an exhaustive list. Thankfully I have constraints to help me make more educated choice.</p>
<ol>
<li><strong>Availability</strong> (in my region) : Even though I can use VPN to appear on some other location on the face of Earth, my bank card will give my location up or won't be accepted 👎️</li>
<li><strong>DRM</strong> : I want to put music on my phone, computer and even my NextCloud to listen from anywhere. When I spent money on music, I don't want to stuck with whatever the vendor supports. I want no vendor lock-in or any other limitation. Those limitations are pushing many people to pirate 😥️</li>
<li><strong>Discoverability</strong> : Whenever there is a new music, I want to be able to find it.</li>
<li><strong>Options</strong> : Does it even has my jazz!</li>
</ol>
<h1>Finally here are my options</h1>
<table>
<thead>
<tr>
<th>Online music stores</th>
<th>Streaming services</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://bandcamp.com/">BandCamp</a></td>
<td><a href="https://www.jamendo.com/">Jamendo</a></td>
</tr>
<tr>
<td><a href="https://www.jamendo.com/">Jamendo</a></td>
<td><a href="https://bandcamp.com/">BandCamp</a></td>
</tr>
</tbody>
</table>
<h2>Why BandCamp</h2>
<p>DRM free songs and musics to purchase and download in high quality. I skimmed over the Term of Services and I dind't notice any red flags for my privacy. It isn't the perfect service. Every artist isn't there and only some of the new songs appear there. But its ToS and Privacy Policy is one of the best ones I skimmed through in a long time.</p>
<h2>Why Jamendo</h2>
<p>Musics licensed under Creative Commons licenses* are available to listen without an account and available to download in high quality with an account. There almost isn't any popular song on Jamendo. But that is an oppportunity to discover new talents. It also has a nice ToS and Privacy Policy.</p>
<h3>I love DRM-free stuff</h3>
<p>As a student living on pocket money, I don't have much of a budget for purchasing music. I am planning to spend 5$ every month on DRM-free musics instead of a streaming service with DRM. I like DRMless content because I know vendor is trusting me. Whenever a platform emposes DRM, I feel treated like a pirate who is expected to steal. No thanks to digital content pirates, I understand why a vendor would put DRM and it is sad that this is the reality. I just am happy that there still are DRM-free alternatives 🙃️</p>
<hr>
<h2>Why not pirate <img height="25em" width="auto" src="https://fosstodon.b-cdn.net/custom_emojis/images/000/083/931/original/a43b334e1ab006d2.png" alt="funny shaped thinking emoji"></h2>
<p>I don't believe pirating is ethical. Someone spent hours coming up with a poem or lyrics, someone else composed music for it, and someone else (probably) drank raw eggs to maintain her/his voice. I wouldn't want people get my hardwork for free unless I put it out there as a demo or as open source. Some people act like pirating is okay if the singer or band is rich. It isn't okay to pirate and I am not giving up on my principles to enjoy some music for free.</p>
<hr>
<p>* Most of the musics on Jamendo are licensed under Non Commercial licenses, such as <a href="https://www.jamendo.com/legal/creative-commons" title="read a little description here">CC BY-NC-SA 4.0</a>. You need to purchase a commercial license to play them in your restaurant, bar, cafe, clothing store, convenience store, market, shopping mall, advertisement, podcast, YouTube/Vimeo/PeerTube video, movie, etc.
You can't play songs from your Spotify account either. Songs on Spotify/Apple Music/YouTube Music and other popular services are for personal listening only too, unless they specifically mention that it is okay to play a song in a venue in music's license. Pijama parties are okay I guess.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104626744957539379">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
@ -241,22 +260,6 @@ You can't play songs from your Spotify account either. Songs on Spotify/Apple Mu
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100daystooffload</a></span> <span>| Day <strong>3</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/resizing-2500-photos.html" rel="bookmark"
title="Permalink to Resizing 2500 photos">Resizing 2500 photos</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>

View File

@ -1,5 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Ali Murteza Yesil</title><link href="https://murtezayesil.me/" rel="alternate"></link><link href="https://murtezayesil.me/feeds/atom.xml" rel="self"></link><id>https://murtezayesil.me/</id><updated>2020-08-11T18:29:00+06:00</updated><subtitle>Blog</subtitle><entry><title>Switching to Bluetooth earphones</title><link href="https://murtezayesil.me/switching-to-bluetooth-earphones.html" rel="alternate"></link><published>2020-08-11T18:29:00+06:00</published><updated>2020-08-11T18:29:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-11:/switching-to-bluetooth-earphones.html</id><summary type="html">&lt;p&gt;After I droped my phone and broke its headphone jack, I had to switch to bluetooth earphone. Redmi Airdots is my choice thanks to its price.&lt;/p&gt;</summary><content type="html">&lt;p&gt;My one and only phone, Andromeda, is a Redmi Note 4. I purchased it 3 years ago. It initially suffered from problems such as consuming battery for self overheating. But I later switched custom ROMs, Lineage and Havoc OS, and battery started to last more than a day. Andromeda served me well in its 3 years of service and it continues to do so albeit with some hickups.&lt;/p&gt;
<feed xmlns="http://www.w3.org/2005/Atom"><title>Ali Murteza Yesil</title><link href="https://murtezayesil.me/" rel="alternate"></link><link href="https://murtezayesil.me/feeds/atom.xml" rel="self"></link><id>https://murtezayesil.me/</id><updated>2020-08-13T07:19:00+06:00</updated><subtitle>Blog</subtitle><entry><title>Resizing 2500 photos</title><link href="https://murtezayesil.me/resizing-2500-photos.html" rel="alternate"></link><published>2020-08-13T07:19:00+06:00</published><updated>2020-08-13T07:19:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-13:/resizing-2500-photos.html</id><summary type="html">&lt;p&gt;We needed to resize 2500 photographs for a website. There is a shell script for that.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used &lt;a href="https://imagemagick.org/"&gt;imagemagick&lt;/a&gt; to write &lt;a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper"&gt;desktop-clock&lt;/a&gt;, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&lt;span class="se"&gt;\ &lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; each image &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; resize to &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;800&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="se"&gt;\_&lt;/span&gt;__________________________/
O
o &lt;span class="se"&gt;\_\_&lt;/span&gt; _/_/
. &lt;span class="se"&gt;\_&lt;/span&gt;_/
&lt;span class="o"&gt;(&lt;/span&gt;oo&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\_&lt;/span&gt;______
&lt;span class="o"&gt;(&lt;/span&gt;__&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\/\&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt;----w &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;This is a learning opportunity&lt;/h1&gt;
&lt;p&gt;Since I don't have much of an experience on shell scripting, I was &lt;a href="https://start.duckduckgo.com/" title="DuckDuckGo"&gt;Duck&lt;/a&gt;ing everything. I learned to do few things during this task.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials"&gt;For loops in shell script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Getting &lt;a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️"&gt;list of files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Correct syntax for &lt;a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️"&gt;resizing with ImageMagick&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. &lt;/p&gt;
&lt;p&gt;Here is &lt;code&gt;image_shrinker.v0.1_alpha.sh&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale 1000000x800 ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This version has problems which I can't call "feature" 😁️ :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.&lt;/li&gt;
&lt;li&gt;Script must be in same directory as images&lt;/li&gt;
&lt;li&gt;PWD must point to the directory where script is&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Adjustable resolution&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$WIDTHx$HEIGHT&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$#&lt;/span&gt; -lt &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;USAGE:&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;&amp;quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in *
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$Resolution&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nv"&gt;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*.*
&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="c1"&gt;# Below code will scale images to 800px height without breaking aspect ratio&lt;/span&gt;
convert &lt;span class="nv"&gt;$DIR&lt;/span&gt;/&lt;span class="nv"&gt;$image&lt;/span&gt; -scale 10000x800 -write &lt;span class="nv"&gt;$DIR&lt;/span&gt;/../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.&lt;/p&gt;</content><category term="Tech"></category><category term="code"></category><category term="100DaysToOffload"></category></entry><entry><title>Switching to Bluetooth earphones</title><link href="https://murtezayesil.me/switching-to-bluetooth-earphones.html" rel="alternate"></link><published>2020-08-11T18:29:00+06:00</published><updated>2020-08-11T18:29:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-11:/switching-to-bluetooth-earphones.html</id><summary type="html">&lt;p&gt;After I droped my phone and broke its headphone jack, I had to switch to bluetooth earphone. Redmi Airdots is my choice thanks to its price.&lt;/p&gt;</summary><content type="html">&lt;p&gt;My one and only phone, Andromeda, is a Redmi Note 4. I purchased it 3 years ago. It initially suffered from problems such as consuming battery for self overheating. But I later switched custom ROMs, Lineage and Havoc OS, and battery started to last more than a day. Andromeda served me well in its 3 years of service and it continues to do so albeit with some hickups.&lt;/p&gt;
&lt;p&gt;I am not the best phone user. I actually am a clumsy person who drops his phone on regular basis. So much so that Andromeda's display got replaced once and glass twice. Its glass is broken as I write these lines 😁️&lt;/p&gt;
&lt;p&gt;But broken glass isn't the issue. It still detects my touches fairly accurately. Real problem is that, a recent drop resulted &lt;strong&gt;front speaker to stop working&lt;/strong&gt; so that I can't hear other person during phone calls and some copper piece come out of headphone jack which rendered &lt;strong&gt;microphone on headsets to not connect&lt;/strong&gt; so that other person cannot hear me during a phone call (if I am using a headphone). My temporary solution was to use loud speaker which is annoying and makes private calls difficult. Also it is rude in public. Another option was bluetooth speaker which requires some budget.&lt;/p&gt;
&lt;p&gt;I could spare 20$ for a pair bluetooth earphones. Pretty generous huh 😜️&lt;br&gt;
@ -551,91 +635,7 @@ This list may get longer as I remember services I subscribed to but didn't use i
I will start with looking for alternatives to Google Drive.&lt;/p&gt;
&lt;p&gt;If there is any other service you think I should stay away from, you can write to comment toot.&lt;br&gt;
If you have written a blog post as an answer, mention that too.&lt;br&gt;
If you think some of the services or softwares I mentioned here aren't that bad and I would be better of keep using them, please share why you think so. I want to keep an open mind and look at those services from your perspective too.&lt;/p&gt;</content><category term="Tech"></category><category term="digitalcleansing"></category><category term="privacy"></category><category term="100daystooffload"></category></entry><entry><title>Resizing 2500 photos</title><link href="https://murtezayesil.me/resizing-2500-photos.html" rel="alternate"></link><published>2020-07-13T07:19:00+06:00</published><updated>2020-07-13T07:19:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-13:/resizing-2500-photos.html</id><summary type="html">&lt;p&gt;We needed to resize 2500 photographs for a website. There is a shell script for that.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used &lt;a href="https://imagemagick.org/"&gt;imagemagick&lt;/a&gt; to write &lt;a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper"&gt;desktop-clock&lt;/a&gt;, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&lt;span class="se"&gt;\ &lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; each image &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; resize to &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;800&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="se"&gt;\_&lt;/span&gt;__________________________/
O
o &lt;span class="se"&gt;\_\_&lt;/span&gt; _/_/
. &lt;span class="se"&gt;\_&lt;/span&gt;_/
&lt;span class="o"&gt;(&lt;/span&gt;oo&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\_&lt;/span&gt;______
&lt;span class="o"&gt;(&lt;/span&gt;__&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\/\&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt;----w &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;This is a learning opportunity&lt;/h1&gt;
&lt;p&gt;Since I don't have much of an experience on shell scripting, I was &lt;a href="https://start.duckduckgo.com/" title="DuckDuckGo"&gt;Duck&lt;/a&gt;ing everything. I learned to do few things during this task.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials"&gt;For loops in shell script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Getting &lt;a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️"&gt;list of files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Correct syntax for &lt;a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️"&gt;resizing with ImageMagick&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. &lt;/p&gt;
&lt;p&gt;Here is &lt;code&gt;image_shrinker.v0.1_alpha.sh&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale 1000000x800 ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This version has problems which I can't call "feature" 😁️ :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.&lt;/li&gt;
&lt;li&gt;Script must be in same directory as images&lt;/li&gt;
&lt;li&gt;PWD must point to the directory where script is&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Adjustable resolution&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$WIDTHx$HEIGHT&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$#&lt;/span&gt; -lt &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;USAGE:&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;&amp;quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in *
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$Resolution&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nv"&gt;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*.*
&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="c1"&gt;# Below code will scale images to 800px height without breaking aspect ratio&lt;/span&gt;
convert &lt;span class="nv"&gt;$DIR&lt;/span&gt;/&lt;span class="nv"&gt;$image&lt;/span&gt; -scale 10000x800 -write &lt;span class="nv"&gt;$DIR&lt;/span&gt;/../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.&lt;/p&gt;</content><category term="Tech"></category><category term="code"></category><category term="100DaysToOffload"></category></entry><entry><title>Digital Cleansing For Better Privacy</title><link href="https://murtezayesil.me/digital-cleansing-for-better-privacy.html" rel="alternate"></link><published>2020-07-12T00:07:00+06:00</published><updated>2020-07-12T00:07:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-12:/digital-cleansing-for-better-privacy.html</id><summary type="html">&lt;p&gt;I am documenting my journey to claiming my digital freedom. Previously called "My Master Plan For Privacy (of my family)".&lt;/p&gt;</summary><content type="html">&lt;p&gt;I previously wrote about &lt;a href="privacy_for_the_whole_family.md" title="Privacy For The Whole Family"&gt;how I got became more privacy caring individual&lt;/a&gt; and I tooted about &lt;a href="https://fosstodon.org/@murtezayesil/104480280886518081"&gt;My Master Plan for Privacy of My Family&lt;/a&gt;. As I grew up, I came to realize how much we gave up on privacy for the convinience and "free" services. We are social creatures. I was using Google Photos, WhatsApp, Youtube and Instagram as much as I could and my family is doing the same. We are putting each other's privacy at stake by uploading data about each other without knowing. I decided to change that either by finding privacy focused alternatives to digital services I was using or by build server system to offer alternatives myself.&lt;/p&gt;
If you think some of the services or softwares I mentioned here aren't that bad and I would be better of keep using them, please share why you think so. I want to keep an open mind and look at those services from your perspective too.&lt;/p&gt;</content><category term="Tech"></category><category term="digitalcleansing"></category><category term="privacy"></category><category term="100daystooffload"></category></entry><entry><title>Digital Cleansing For Better Privacy</title><link href="https://murtezayesil.me/digital-cleansing-for-better-privacy.html" rel="alternate"></link><published>2020-07-12T00:07:00+06:00</published><updated>2020-07-12T00:07:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-12:/digital-cleansing-for-better-privacy.html</id><summary type="html">&lt;p&gt;I am documenting my journey to claiming my digital freedom. Previously called "My Master Plan For Privacy (of my family)".&lt;/p&gt;</summary><content type="html">&lt;p&gt;I previously wrote about &lt;a href="privacy_for_the_whole_family.md" title="Privacy For The Whole Family"&gt;how I got became more privacy caring individual&lt;/a&gt; and I tooted about &lt;a href="https://fosstodon.org/@murtezayesil/104480280886518081"&gt;My Master Plan for Privacy of My Family&lt;/a&gt;. As I grew up, I came to realize how much we gave up on privacy for the convinience and "free" services. We are social creatures. I was using Google Photos, WhatsApp, Youtube and Instagram as much as I could and my family is doing the same. We are putting each other's privacy at stake by uploading data about each other without knowing. I decided to change that either by finding privacy focused alternatives to digital services I was using or by build server system to offer alternatives myself.&lt;/p&gt;
&lt;p&gt;I am not the first to do this. There are many privacy friendly alternatives developed by people who care about privacy. It isn't hard to find those &lt;a href="https://alternativeto.net/" title="Crowdsourced Software Recomendations"&gt;alternatives&lt;/a&gt;. Many people went through this journey, which I call "Digital Cleansing For Better Privacy". During my journey, I will document the steps I have taken and write my thoughts about the alternatives I tried.&lt;/p&gt;
&lt;hr&gt;
&lt;h1&gt;Digital Cleansing For Better Privacy&lt;/h1&gt;

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Ali Murteza Yesil - Tech</title><link href="https://murtezayesil.me/" rel="alternate"></link><link href="https://murtezayesil.me/feeds/tech.atom.xml" rel="self"></link><id>https://murtezayesil.me/</id><updated>2020-08-03T15:00:00+06:00</updated><subtitle>Blog</subtitle><entry><title>Digital Cleansing - Music</title><link href="https://murtezayesil.me/digital-cleansing-music.html" rel="alternate"></link><published>2020-08-03T15:00:00+06:00</published><updated>2020-08-03T15:00:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-03:/digital-cleansing-music.html</id><summary type="html">&lt;p&gt;There aren't many options to buy DRM free music, are there!&lt;/p&gt;</summary><content type="html">&lt;p&gt;I like listening to musics and I am not the only one. Just look at how many people are listening to &lt;a href="https://www.youtube.com/watch?v=5qap5aO4i9A" title="lofi hip hop radio - beats to relax/study to on YouTube"&gt;LoFi music with the study girl&lt;/a&gt; or look how many views &lt;a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"&gt;this song&lt;/a&gt; has. As a young adult, I remember the times the CDs were the king of music distribution. But they are long gone. Thanks to internet, digital music stores and music streaming services replaced CDs.&lt;br&gt;
<feed xmlns="http://www.w3.org/2005/Atom"><title>Ali Murteza Yesil - Tech</title><link href="https://murtezayesil.me/" rel="alternate"></link><link href="https://murtezayesil.me/feeds/tech.atom.xml" rel="self"></link><id>https://murtezayesil.me/</id><updated>2020-08-13T07:19:00+06:00</updated><subtitle>Blog</subtitle><entry><title>Resizing 2500 photos</title><link href="https://murtezayesil.me/resizing-2500-photos.html" rel="alternate"></link><published>2020-08-13T07:19:00+06:00</published><updated>2020-08-13T07:19:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-13:/resizing-2500-photos.html</id><summary type="html">&lt;p&gt;We needed to resize 2500 photographs for a website. There is a shell script for that.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used &lt;a href="https://imagemagick.org/"&gt;imagemagick&lt;/a&gt; to write &lt;a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper"&gt;desktop-clock&lt;/a&gt;, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&lt;span class="se"&gt;\ &lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; each image &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; resize to &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;800&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="se"&gt;\_&lt;/span&gt;__________________________/
O
o &lt;span class="se"&gt;\_\_&lt;/span&gt; _/_/
. &lt;span class="se"&gt;\_&lt;/span&gt;_/
&lt;span class="o"&gt;(&lt;/span&gt;oo&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\_&lt;/span&gt;______
&lt;span class="o"&gt;(&lt;/span&gt;__&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\/\&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt;----w &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;This is a learning opportunity&lt;/h1&gt;
&lt;p&gt;Since I don't have much of an experience on shell scripting, I was &lt;a href="https://start.duckduckgo.com/" title="DuckDuckGo"&gt;Duck&lt;/a&gt;ing everything. I learned to do few things during this task.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials"&gt;For loops in shell script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Getting &lt;a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️"&gt;list of files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Correct syntax for &lt;a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️"&gt;resizing with ImageMagick&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. &lt;/p&gt;
&lt;p&gt;Here is &lt;code&gt;image_shrinker.v0.1_alpha.sh&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale 1000000x800 ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This version has problems which I can't call "feature" 😁️ :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.&lt;/li&gt;
&lt;li&gt;Script must be in same directory as images&lt;/li&gt;
&lt;li&gt;PWD must point to the directory where script is&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Adjustable resolution&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$WIDTHx$HEIGHT&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$#&lt;/span&gt; -lt &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;USAGE:&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;&amp;quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in *
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$Resolution&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nv"&gt;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*.*
&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="c1"&gt;# Below code will scale images to 800px height without breaking aspect ratio&lt;/span&gt;
convert &lt;span class="nv"&gt;$DIR&lt;/span&gt;/&lt;span class="nv"&gt;$image&lt;/span&gt; -scale 10000x800 -write &lt;span class="nv"&gt;$DIR&lt;/span&gt;/../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.&lt;/p&gt;</content><category term="Tech"></category><category term="code"></category><category term="100DaysToOffload"></category></entry><entry><title>Digital Cleansing - Music</title><link href="https://murtezayesil.me/digital-cleansing-music.html" rel="alternate"></link><published>2020-08-03T15:00:00+06:00</published><updated>2020-08-03T15:00:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-08-03:/digital-cleansing-music.html</id><summary type="html">&lt;p&gt;There aren't many options to buy DRM free music, are there!&lt;/p&gt;</summary><content type="html">&lt;p&gt;I like listening to musics and I am not the only one. Just look at how many people are listening to &lt;a href="https://www.youtube.com/watch?v=5qap5aO4i9A" title="lofi hip hop radio - beats to relax/study to on YouTube"&gt;LoFi music with the study girl&lt;/a&gt; or look how many views &lt;a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"&gt;this song&lt;/a&gt; has. As a young adult, I remember the times the CDs were the king of music distribution. But they are long gone. Thanks to internet, digital music stores and music streaming services replaced CDs.&lt;br&gt;
So here I am, looking for the best music listening solution I can get. After a little search on the internet I came up with the below list of music stores or streaming services.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
@ -329,91 +413,7 @@ This list may get longer as I remember services I subscribed to but didn't use i
I will start with looking for alternatives to Google Drive.&lt;/p&gt;
&lt;p&gt;If there is any other service you think I should stay away from, you can write to comment toot.&lt;br&gt;
If you have written a blog post as an answer, mention that too.&lt;br&gt;
If you think some of the services or softwares I mentioned here aren't that bad and I would be better of keep using them, please share why you think so. I want to keep an open mind and look at those services from your perspective too.&lt;/p&gt;</content><category term="Tech"></category><category term="digitalcleansing"></category><category term="privacy"></category><category term="100daystooffload"></category></entry><entry><title>Resizing 2500 photos</title><link href="https://murtezayesil.me/resizing-2500-photos.html" rel="alternate"></link><published>2020-07-13T07:19:00+06:00</published><updated>2020-07-13T07:19:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-13:/resizing-2500-photos.html</id><summary type="html">&lt;p&gt;We needed to resize 2500 photographs for a website. There is a shell script for that.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used &lt;a href="https://imagemagick.org/"&gt;imagemagick&lt;/a&gt; to write &lt;a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper"&gt;desktop-clock&lt;/a&gt;, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&lt;span class="se"&gt;\ &lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; each image &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; resize to &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;800&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="se"&gt;\_&lt;/span&gt;__________________________/
O
o &lt;span class="se"&gt;\_\_&lt;/span&gt; _/_/
. &lt;span class="se"&gt;\_&lt;/span&gt;_/
&lt;span class="o"&gt;(&lt;/span&gt;oo&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\_&lt;/span&gt;______
&lt;span class="o"&gt;(&lt;/span&gt;__&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\/\&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt;----w &lt;span class="p"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1&gt;This is a learning opportunity&lt;/h1&gt;
&lt;p&gt;Since I don't have much of an experience on shell scripting, I was &lt;a href="https://start.duckduckgo.com/" title="DuckDuckGo"&gt;Duck&lt;/a&gt;ing everything. I learned to do few things during this task.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials"&gt;For loops in shell script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Getting &lt;a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️"&gt;list of files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Correct syntax for &lt;a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️"&gt;resizing with ImageMagick&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. &lt;/p&gt;
&lt;p&gt;Here is &lt;code&gt;image_shrinker.v0.1_alpha.sh&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale 1000000x800 ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This version has problems which I can't call "feature" 😁️ :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.&lt;/li&gt;
&lt;li&gt;Script must be in same directory as images&lt;/li&gt;
&lt;li&gt;PWD must point to the directory where script is&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Adjustable resolution&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
mkdir ../output
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$WIDTHx$HEIGHT&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$#&lt;/span&gt; -lt &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;USAGE:&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; -e &lt;span class="s2"&gt;&amp;quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nv"&gt;WIDTH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;HEIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
mkdir ../output
&lt;span class="k"&gt;for&lt;/span&gt; image in *
&lt;span class="k"&gt;do&lt;/span&gt;
convert &lt;span class="nv"&gt;$image&lt;/span&gt; -scale &lt;span class="nv"&gt;$Resolution&lt;/span&gt; ../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nv"&gt;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; image in ./*.*
&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="c1"&gt;# Below code will scale images to 800px height without breaking aspect ratio&lt;/span&gt;
convert &lt;span class="nv"&gt;$DIR&lt;/span&gt;/&lt;span class="nv"&gt;$image&lt;/span&gt; -scale 10000x800 -write &lt;span class="nv"&gt;$DIR&lt;/span&gt;/../output/&lt;span class="nv"&gt;$image&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.&lt;/p&gt;</content><category term="Tech"></category><category term="code"></category><category term="100DaysToOffload"></category></entry><entry><title>Digital Cleansing For Better Privacy</title><link href="https://murtezayesil.me/digital-cleansing-for-better-privacy.html" rel="alternate"></link><published>2020-07-12T00:07:00+06:00</published><updated>2020-07-12T00:07:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-12:/digital-cleansing-for-better-privacy.html</id><summary type="html">&lt;p&gt;I am documenting my journey to claiming my digital freedom. Previously called "My Master Plan For Privacy (of my family)".&lt;/p&gt;</summary><content type="html">&lt;p&gt;I previously wrote about &lt;a href="privacy_for_the_whole_family.md" title="Privacy For The Whole Family"&gt;how I got became more privacy caring individual&lt;/a&gt; and I tooted about &lt;a href="https://fosstodon.org/@murtezayesil/104480280886518081"&gt;My Master Plan for Privacy of My Family&lt;/a&gt;. As I grew up, I came to realize how much we gave up on privacy for the convinience and "free" services. We are social creatures. I was using Google Photos, WhatsApp, Youtube and Instagram as much as I could and my family is doing the same. We are putting each other's privacy at stake by uploading data about each other without knowing. I decided to change that either by finding privacy focused alternatives to digital services I was using or by build server system to offer alternatives myself.&lt;/p&gt;
If you think some of the services or softwares I mentioned here aren't that bad and I would be better of keep using them, please share why you think so. I want to keep an open mind and look at those services from your perspective too.&lt;/p&gt;</content><category term="Tech"></category><category term="digitalcleansing"></category><category term="privacy"></category><category term="100daystooffload"></category></entry><entry><title>Digital Cleansing For Better Privacy</title><link href="https://murtezayesil.me/digital-cleansing-for-better-privacy.html" rel="alternate"></link><published>2020-07-12T00:07:00+06:00</published><updated>2020-07-12T00:07:00+06:00</updated><author><name>Ali Murteza Yesil</name></author><id>tag:murtezayesil.me,2020-07-12:/digital-cleansing-for-better-privacy.html</id><summary type="html">&lt;p&gt;I am documenting my journey to claiming my digital freedom. Previously called "My Master Plan For Privacy (of my family)".&lt;/p&gt;</summary><content type="html">&lt;p&gt;I previously wrote about &lt;a href="privacy_for_the_whole_family.md" title="Privacy For The Whole Family"&gt;how I got became more privacy caring individual&lt;/a&gt; and I tooted about &lt;a href="https://fosstodon.org/@murtezayesil/104480280886518081"&gt;My Master Plan for Privacy of My Family&lt;/a&gt;. As I grew up, I came to realize how much we gave up on privacy for the convinience and "free" services. We are social creatures. I was using Google Photos, WhatsApp, Youtube and Instagram as much as I could and my family is doing the same. We are putting each other's privacy at stake by uploading data about each other without knowing. I decided to change that either by finding privacy focused alternatives to digital services I was using or by build server system to offer alternatives myself.&lt;/p&gt;
&lt;p&gt;I am not the first to do this. There are many privacy friendly alternatives developed by people who care about privacy. It isn't hard to find those &lt;a href="https://alternativeto.net/" title="Crowdsourced Software Recomendations"&gt;alternatives&lt;/a&gt;. Many people went through this journey, which I call "Digital Cleansing For Better Privacy". During my journey, I will document the steps I have taken and write my thoughts about the alternatives I tried.&lt;/p&gt;
&lt;hr&gt;
&lt;h1&gt;Digital Cleansing For Better Privacy&lt;/h1&gt;

View File

@ -50,32 +50,122 @@
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html">Switching to Bluetooth earphones</a></h1>
<h1 class="entry-title"><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></h1>
<footer class="post-info">
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used <a href="https://imagemagick.org/">imagemagick</a> to write <a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper">desktop-clock</a>, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.</p>
<div class="highlight"><pre><span></span><code>/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾<span class="se">\ </span>
<span class="p">|</span> <span class="k">for</span> each image <span class="p">|</span>
<span class="p">|</span> <span class="k">do</span> resize to <span class="nv">height</span><span class="o">=</span><span class="m">800</span> <span class="p">|</span>
<span class="se">\_</span>__________________________/
O
o <span class="se">\_\_</span> _/_/
. <span class="se">\_</span>_/
<span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="o">(</span>__<span class="o">)</span><span class="se">\ </span> <span class="o">)</span><span class="se">\/\</span>
<span class="o">||</span>----w <span class="p">|</span>
<span class="o">||</span> <span class="o">||</span>
</code></pre></div>
<h1>This is a learning opportunity</h1>
<p>Since I don't have much of an experience on shell scripting, I was <a href="https://start.duckduckgo.com/" title="DuckDuckGo">Duck</a>ing everything. I learned to do few things during this task.</p>
<ol>
<li><a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials">For loops in shell script</a></li>
<li>Getting <a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️">list of files</a></li>
<li>Correct syntax for <a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️">resizing with ImageMagick</a></li>
</ol>
<p>After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. </p>
<p>Here is <code>image_shrinker.v0.1_alpha.sh</code> :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale 1000000x800 ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This version has problems which I can't call "feature" 😁️ :</p>
<ol>
<li>Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.</li>
<li>Script must be in same directory as images</li>
<li>PWD must point to the directory where script is</li>
</ol>
<h2>Adjustable resolution</h2>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$WIDTHx$HEIGHT</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$#</span> -lt <span class="m">2</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="s2">&quot;USAGE:&quot;</span>
<span class="nb">echo</span> -e <span class="s2">&quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&quot;</span>
<span class="nb">exit</span> <span class="m">1</span>
<span class="k">fi</span>
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
mkdir ../output
<span class="k">for</span> image in *
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$Resolution</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">DIR</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
<span class="k">for</span> image in ./*.*
<span class="k">do</span>
<span class="c1"># Below code will scale images to 800px height without breaking aspect ratio</span>
convert <span class="nv">$DIR</span>/<span class="nv">$image</span> -scale 10000x800 -write <span class="nv">$DIR</span>/../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html" rel="bookmark"
title="Permalink to Switching to Bluetooth earphones">Switching to Bluetooth earphones</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Tue 11 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/personal.html">Personal</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>17</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>My one and only phone, Andromeda, is a Redmi Note 4. I purchased it 3 years ago. It initially suffered from problems such as consuming battery for self overheating. But I later switched custom ROMs, Lineage and Havoc OS, and battery started to last more than a day. Andromeda served me well in its 3 years of service and it continues to do so albeit with some hickups.</p>
<p>I am not the best phone user. I actually am a clumsy person who drops his phone on regular basis. So much so that Andromeda's display got replaced once and glass twice. Its glass is broken as I write these lines 😁️</p>
<p>But broken glass isn't the issue. It still detects my touches fairly accurately. Real problem is that, a recent drop resulted <strong>front speaker to stop working</strong> so that I can't hear other person during phone calls and some copper piece come out of headphone jack which rendered <strong>microphone on headsets to not connect</strong> so that other person cannot hear me during a phone call (if I am using a headphone). My temporary solution was to use loud speaker which is annoying and makes private calls difficult. Also it is rude in public. Another option was bluetooth speaker which requires some budget.</p>
<p>I could spare 20$ for a pair bluetooth earphones. Pretty generous huh 😜️<br>
Anyway, after some market search I set my mind on Redmi Airdots.</p>
<p><strong>Do I recommend them?</strong><br>
No and Yes. They aren't the best earphones, not even best in-ear earphones, but they are affordable.<br>
Just like every other in-ear earphones, they aren't comfortable even after I replaced the tips with different size that better fits 😕️ They will do for now. It isn't too much of a deal since I am planning to use them only for calls. Speakers on wired earphones still work with the phone fortunately.</p>
<div style="text-align: center;">
<img src="images/memes/modern_problems_bluetooth_earphones.jpg" alt="Top Caption: Switched to Bluetooth earphones after phone's headphone jack. Bottom Caption: Modern problems require modern solutions">
</div><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104672484458036109">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
@ -202,22 +292,6 @@ Just like every other in-ear earphones, they aren't comfortable even after I rep
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>9</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
</ol><!-- /#posts-list -->

View File

@ -50,6 +50,22 @@
<section id="content" class="body">
<ol id="posts-list" class="hfeed" start="9">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/adb_vendor_keys-is-not-set.html" rel="bookmark"
@ -127,22 +143,6 @@
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100daystooffload</a></span> <span>| Day <strong>3</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/resizing-2500-photos.html" rel="bookmark"
title="Permalink to Resizing 2500 photos">Resizing 2500 photos</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>

View File

@ -57,7 +57,7 @@
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
@ -152,6 +152,10 @@ mkdir ../output
<!-- #100DaysToOffload message -->
<p>Day <strong>18</strong> of <a href="https://100daystooffload.com/" title="click to read about the challenge">#100DaysToOffload</a></p>
<!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>

View File

@ -50,32 +50,122 @@
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html">Switching to Bluetooth earphones</a></h1>
<h1 class="entry-title"><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></h1>
<footer class="post-info">
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used <a href="https://imagemagick.org/">imagemagick</a> to write <a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper">desktop-clock</a>, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.</p>
<div class="highlight"><pre><span></span><code>/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾<span class="se">\ </span>
<span class="p">|</span> <span class="k">for</span> each image <span class="p">|</span>
<span class="p">|</span> <span class="k">do</span> resize to <span class="nv">height</span><span class="o">=</span><span class="m">800</span> <span class="p">|</span>
<span class="se">\_</span>__________________________/
O
o <span class="se">\_\_</span> _/_/
. <span class="se">\_</span>_/
<span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="o">(</span>__<span class="o">)</span><span class="se">\ </span> <span class="o">)</span><span class="se">\/\</span>
<span class="o">||</span>----w <span class="p">|</span>
<span class="o">||</span> <span class="o">||</span>
</code></pre></div>
<h1>This is a learning opportunity</h1>
<p>Since I don't have much of an experience on shell scripting, I was <a href="https://start.duckduckgo.com/" title="DuckDuckGo">Duck</a>ing everything. I learned to do few things during this task.</p>
<ol>
<li><a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials">For loops in shell script</a></li>
<li>Getting <a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️">list of files</a></li>
<li>Correct syntax for <a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️">resizing with ImageMagick</a></li>
</ol>
<p>After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. </p>
<p>Here is <code>image_shrinker.v0.1_alpha.sh</code> :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale 1000000x800 ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This version has problems which I can't call "feature" 😁️ :</p>
<ol>
<li>Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.</li>
<li>Script must be in same directory as images</li>
<li>PWD must point to the directory where script is</li>
</ol>
<h2>Adjustable resolution</h2>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$WIDTHx$HEIGHT</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$#</span> -lt <span class="m">2</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="s2">&quot;USAGE:&quot;</span>
<span class="nb">echo</span> -e <span class="s2">&quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&quot;</span>
<span class="nb">exit</span> <span class="m">1</span>
<span class="k">fi</span>
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
mkdir ../output
<span class="k">for</span> image in *
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$Resolution</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">DIR</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
<span class="k">for</span> image in ./*.*
<span class="k">do</span>
<span class="c1"># Below code will scale images to 800px height without breaking aspect ratio</span>
convert <span class="nv">$DIR</span>/<span class="nv">$image</span> -scale 10000x800 -write <span class="nv">$DIR</span>/../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/switching-to-bluetooth-earphones.html" rel="bookmark"
title="Permalink to Switching to Bluetooth earphones">Switching to Bluetooth earphones</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Tue 11 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/personal.html">Personal</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>17</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>My one and only phone, Andromeda, is a Redmi Note 4. I purchased it 3 years ago. It initially suffered from problems such as consuming battery for self overheating. But I later switched custom ROMs, Lineage and Havoc OS, and battery started to last more than a day. Andromeda served me well in its 3 years of service and it continues to do so albeit with some hickups.</p>
<p>I am not the best phone user. I actually am a clumsy person who drops his phone on regular basis. So much so that Andromeda's display got replaced once and glass twice. Its glass is broken as I write these lines 😁️</p>
<p>But broken glass isn't the issue. It still detects my touches fairly accurately. Real problem is that, a recent drop resulted <strong>front speaker to stop working</strong> so that I can't hear other person during phone calls and some copper piece come out of headphone jack which rendered <strong>microphone on headsets to not connect</strong> so that other person cannot hear me during a phone call (if I am using a headphone). My temporary solution was to use loud speaker which is annoying and makes private calls difficult. Also it is rude in public. Another option was bluetooth speaker which requires some budget.</p>
<p>I could spare 20$ for a pair bluetooth earphones. Pretty generous huh 😜️<br>
Anyway, after some market search I set my mind on Redmi Airdots.</p>
<p><strong>Do I recommend them?</strong><br>
No and Yes. They aren't the best earphones, not even best in-ear earphones, but they are affordable.<br>
Just like every other in-ear earphones, they aren't comfortable even after I replaced the tips with different size that better fits 😕️ They will do for now. It isn't too much of a deal since I am planning to use them only for calls. Speakers on wired earphones still work with the phone fortunately.</p>
<div style="text-align: center;">
<img src="images/memes/modern_problems_bluetooth_earphones.jpg" alt="Top Caption: Switched to Bluetooth earphones after phone's headphone jack. Bottom Caption: Modern problems require modern solutions">
</div><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104672484458036109">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
<h1>Other articles</h1>
<ol id="posts-list" class="hfeed">
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
@ -202,22 +292,6 @@ Just like every other in-ear earphones, they aren't comfortable even after I rep
<span>| tags: <a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>9</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
</ol><!-- /#posts-list -->

View File

@ -50,6 +50,22 @@
<section id="content" class="body">
<ol id="posts-list" class="hfeed" start="9">
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/digital-cleansing-mastodon.html" rel="bookmark"
title="Permalink to Digital Cleansing - Mastodon">Digital Cleansing - Mastodon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Fri 24 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/fediverse.html">fediverse</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>8</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/adb_vendor_keys-is-not-set.html" rel="bookmark"
@ -127,22 +143,6 @@
<span>| tags: <a href="https://murtezayesil.me/tag/digitalcleansing.html">digitalcleansing</a><a href="https://murtezayesil.me/tag/privacy.html">privacy</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100daystooffload</a></span> <span>| Day <strong>3</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/resizing-2500-photos.html" rel="bookmark"
title="Permalink to Resizing 2500 photos">Resizing 2500 photos</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->
</article></li>

View File

@ -50,44 +50,101 @@
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="https://murtezayesil.me/fizzbuzz-with-single-semicolon.html">FizzBuzz with single semicolon</a></h1>
<h1 class="entry-title"><a href="https://murtezayesil.me/resizing-2500-photos.html">Resizing 2500 photos</a></h1>
<footer class="post-info">
<span>Mon 20 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/notes.html">Notes</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>6</strong> of #100DaysToOffload</span>
<span>Thu 13 August 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --><p>Semicolon is a bit special in Rust. It only comes after statements, not expressions. that includes codeblock returns. This gave me a silly idea.</p>
<h2>How many semicolons needed to write a FizzBuzz program in Rust?</h2>
<div class="highlight"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="c1">// for every number from 1 to 100</span>
<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">number</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">1</span><span class="o">..</span><span class="mi">100</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="w"></span>
<span class="w"> </span><span class="s">&quot;{}&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="c1">// check if number is</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">number</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">15</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// divisible by both 3 &amp; 5</span>
<span class="w"> </span><span class="s">&quot;fizzbuzz&quot;</span><span class="p">.</span><span class="n">to_string</span><span class="p">()</span><span class="w"> </span><span class="c1">// if so return &quot;fizzbuzz&quot;</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">number</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// divisible by 3</span>
<span class="w"> </span><span class="s">&quot;fizz&quot;</span><span class="p">.</span><span class="n">to_string</span><span class="p">()</span><span class="w"> </span><span class="c1">// if so return &quot;fizz&quot;</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">number</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">5</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// divisible by 5</span>
<span class="w"> </span><span class="s">&quot;buzz&quot;</span><span class="p">.</span><span class="n">to_string</span><span class="p">()</span><span class="w"> </span><span class="c1">// if so return &quot;buzz&quot;</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// but if not</span>
<span class="w"> </span><span class="n">number</span><span class="p">.</span><span class="n">to_string</span><span class="p">()</span><span class="w"> </span><span class="c1">// return number as String</span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="p">);</span><span class="w"> </span><span class="c1">// print returned value</span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</footer><!-- /.post-info --><p>I was asked to write a program to resize thousands of images which were gonna be uploaded to a website. Images had to be the same height for them to look organized in gallery. I remembered how I used <a href="https://imagemagick.org/">imagemagick</a> to write <a href="https://gitlab.com/murtezayesil/student/-/tree/master/sh/desktop-clock" title="use imagemagick, figlet and feh for tty-clock on wallpaper">desktop-clock</a>, immitate tty-clock on wallpaper. That experience helped me to design the program in my mind as we continue to speak on the phone.</p>
<div class="highlight"><pre><span></span><code>/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾<span class="se">\ </span>
<span class="p">|</span> <span class="k">for</span> each image <span class="p">|</span>
<span class="p">|</span> <span class="k">do</span> resize to <span class="nv">height</span><span class="o">=</span><span class="m">800</span> <span class="p">|</span>
<span class="se">\_</span>__________________________/
O
o <span class="se">\_\_</span> _/_/
. <span class="se">\_</span>_/
<span class="o">(</span>oo<span class="o">)</span><span class="se">\_</span>______
<span class="o">(</span>__<span class="o">)</span><span class="se">\ </span> <span class="o">)</span><span class="se">\/\</span>
<span class="o">||</span>----w <span class="p">|</span>
<span class="o">||</span> <span class="o">||</span>
</code></pre></div>
<h1 style="text-align: center;">1</h1>
<h1>This is a learning opportunity</h1>
<p>Since I don't have much of an experience on shell scripting, I was <a href="https://start.duckduckgo.com/" title="DuckDuckGo">Duck</a>ing everything. I learned to do few things during this task.</p>
<ol>
<li><a href="https://duckduckgo.com/?q=for+loop+shell+script" title="There are many tutorials">For loops in shell script</a></li>
<li>Getting <a href="https://stackoverflow.com/questions/2437452/how-to-get-the-list-of-files-in-a-directory-in-a-shell-script" title="I didn't know how to use asteriks 😅️">list of files</a></li>
<li>Correct syntax for <a href="https://imagemagick.org/script/convert.php" title="It ain't magick but it quiet is 😉️">resizing with ImageMagick</a></li>
</ol>
<p>After reading tutorials and looking at examples everything felt as simple as lego. I just needed to put them together. </p>
<p>Here is <code>image_shrinker.v0.1_alpha.sh</code> :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale 1000000x800 ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>There is also <a href="https://github.com/Keith-S-Thompson/fizzbuzz-c/blob/master/fizzbuzz004.c" title="Brute forcing FizzBuzz in C">brute forcing method</a> 🤦‍♂️️</p><!-- Comments -->
<p>This version has problems which I can't call "feature" 😁️ :</p>
<ol>
<li>Resolution is hard coded. Btw, only way to define resolution is in WIDTHxHEIGHT format AFAIK.</li>
<li>Script must be in same directory as images</li>
<li>PWD must point to the directory where script is</li>
</ol>
<h2>Adjustable resolution</h2>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
mkdir ../output
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
<span class="k">for</span> image in ./*
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$WIDTHx$HEIGHT</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>This fixes the hard coded resolution problem but new problem is that the user has to know that WIDTH and HEIGHT must be given. I fix that by showing correct syntax to the user and then exiting :</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$#</span> -lt <span class="m">2</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="s2">&quot;USAGE:&quot;</span>
<span class="nb">echo</span> -e <span class="s2">&quot;\t\$IMAGE_DIRECTORY/image_shrinker.sh WIDTH HEIGHT&quot;</span>
<span class="nb">exit</span> <span class="m">1</span>
<span class="k">fi</span>
<span class="nv">WIDTH</span><span class="o">=</span><span class="nv">$1</span> <span class="p">;</span> <span class="nv">HEIGHT</span><span class="o">=</span><span class="nv">$2</span>
mkdir ../output
<span class="k">for</span> image in *
<span class="k">do</span>
convert <span class="nv">$image</span> -scale <span class="nv">$Resolution</span> ../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>Here is some other attempt to make code a bit more flexible in terms of where images can be and where output can go. Actually no but that is what I was going for 😜️</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/sh</span>
<span class="nv">DIR</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
<span class="k">for</span> image in ./*.*
<span class="k">do</span>
<span class="c1"># Below code will scale images to 800px height without breaking aspect ratio</span>
convert <span class="nv">$DIR</span>/<span class="nv">$image</span> -scale 10000x800 -write <span class="nv">$DIR</span>/../output/<span class="nv">$image</span>
<span class="k">done</span>
</code></pre></div>
<p>It is hard to ask for help (especially after torturing with my code) but if you would like to give me feedback and advice, reply to toot of this post.</p><!-- Comments -->
<hr>
<h2>Comments</h2>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104552527725862495">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
<p>Toot on <a href="https://fosstodon.org/@murtezayesil/104681372709677657">this thread</a> to comment. This blog is a static site. Comments won't appear here.</p>
</article>
</aside><!-- /#featured -->
<section id="content" class="body">
@ -96,15 +153,15 @@
<li><article class="hentry">
<header>
<h1><a href="https://murtezayesil.me/resizing-2500-photos.html" rel="bookmark"
title="Permalink to Resizing 2500 photos">Resizing 2500 photos</a></h1>
<h1><a href="https://murtezayesil.me/fizzbuzz-with-single-semicolon.html" rel="bookmark"
title="Permalink to FizzBuzz with single semicolon">FizzBuzz with single semicolon</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<span>Mon 13 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/tech.html">Tech</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>18</strong> of #100DaysToOffload</span>
<span>Mon 20 July 2020</span>
<span>| in <a href="https://murtezayesil.me/category/notes.html">Notes</a></span>
<span>| tags: <a href="https://murtezayesil.me/tag/code.html">code</a><a href="https://murtezayesil.me/tag/100daystooffload.html">100DaysToOffload</a></span> <span>| Day <strong>6</strong> of #100DaysToOffload</span>
</footer><!-- /.post-info --> </div><!-- /.entry-content -->