snipt

Ctrl+h for KB shortcuts

Bash

Use Imagemagick to convert EPS to PNG

1
2
3
for f in `ls *.eps`; do
    convert -density 100 $f -flatten ${f%.*}.png;
done
https://snipt.net/embed/fc9757923e8ee51be0343f4cff04a292/
https://snipt.net/raw/fc9757923e8ee51be0343f4cff04a292/
fc9757923e8ee51be0343f4cff04a292
bash
Bash
3
2016-10-01T04:40:04
True
False
False
Jul 07, 2014 at 11:47 AM
/api/public/snipt/135711/
use-imagemagick-to-convert-eps-to-png-87cbddba
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">for</span> f in <span class="sb">`</span>ls *.eps<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> </span><span id="L-2"><a name="L-2"></a> convert -density <span class="m">100</span> <span class="nv">$f</span> -flatten <span class="si">${</span><span class="nv">f</span><span class="p">%.*</span><span class="si">}</span>.png<span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">done</span> </span></pre></div> </td></tr></table>
eps, imagemagick, png

Bash

ImageMagick list supported formats

$ identify -list format|grep -i webp
https://snipt.net/embed/4435a262d53e289d0f8ba79119675c06/
https://snipt.net/raw/4435a262d53e289d0f8ba79119675c06/
4435a262d53e289d0f8ba79119675c06
bash
Bash
1
2016-10-01T09:26:47
True
False
False
/api/public/snipt/135538/
imagemagick-list-supported-formats-8e405b30
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">$ </span>identify -list format<span class="p">|</span>grep -i webp </span></pre></div> </td></tr></table>
bash, conversion, imagemagick

Bash

OSX install imagemagick with WEBP and TIFF support

$ brew install imagemagick --with-webp --with-libtiff
https://snipt.net/embed/7776a00a6468dbe85bb3eb07f987c85a/
https://snipt.net/raw/7776a00a6468dbe85bb3eb07f987c85a/
7776a00a6468dbe85bb3eb07f987c85a
bash
Bash
1
2016-10-01T09:26:47
True
False
False
/api/public/snipt/135508/
osx-install-imagemagick-with-webp-and-tiff-support-27ac9e32
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">$ </span>brew install imagemagick --with-webp --with-libtiff </span></pre></div> </td></tr></table>
bash, imagemagick

Bash Session

Batch convert files using imagemagick (on OSX or Linux)

1
2
3
# To make the output name the same as the input name and resize preserving aspect ratio.

$ for file in *.png; do convert $file -resize 80% $file;done
https://snipt.net/embed/8d0a9a5394a77f52f76a250834a483eb/
https://snipt.net/raw/8d0a9a5394a77f52f76a250834a483eb/
8d0a9a5394a77f52f76a250834a483eb
console
Bash Session
3
2016-09-30T22:22:39
True
False
False
Feb 12, 2013 at 01:56 PM
/api/public/snipt/55645/
batch-convert-files-using-imagemagick-on-osx-or-linux
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="gp">#</span> To make the output name the same as the input name and resize preserving aspect ratio. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="gp">$</span> <span class="k">for</span> file in *.png<span class="p">;</span> <span class="k">do</span> convert <span class="nv">$file</span> -resize 80% <span class="nv">$file</span><span class="p">;</span><span class="k">done</span> </span></pre></div> </td></tr></table>
imagemagick

Bash

find *.jpgs in current folder/subfolders > 500k and convert (via imagemagick) to quality 80%

$ find . -type f -size +500k -iname "*.jpg" -exec convert \{\} -quality 80 \{\} \;
https://snipt.net/embed/c4cfb60a6416d201afea8e025c01df88/
https://snipt.net/raw/c4cfb60a6416d201afea8e025c01df88/
c4cfb60a6416d201afea8e025c01df88
bash
Bash
1
2016-10-01T02:15:29
True
False
False
/api/public/snipt/49348/
find-jpgs-in-current-foldersubfolders-500k-and-convert-via-imagemagick-to-quality-80
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">$ </span>find . -type f -size +500k -iname <span class="s2">&quot;*.jpg&quot;</span> -exec convert <span class="se">\{\}</span> -quality <span class="m">80</span> <span class="se">\{\}</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
bash, convert, find, image, imagemagick, jpg, optimize

Bash

Image to pencil sketch

convert input.jpg -colorspace gray \( +clone -blur 0x2 \) +swap -compose divide -composite -linear-stretch 5%x0% output.jpg
https://snipt.net/embed/3e72931cf386f302f5f385d9e8c3a683/
https://snipt.net/raw/3e72931cf386f302f5f385d9e8c3a683/
3e72931cf386f302f5f385d9e8c3a683
bash
Bash
1
2016-10-01T08:58:21
True
False
False
/api/public/snipt/42309/
image-to-pencil-sketch
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>convert input.jpg -colorspace gray <span class="se">\(</span> +clone -blur 0x2 <span class="se">\)</span> +swap -compose divide -composite -linear-stretch 5%x0% output.jpg </span></pre></div> </td></tr></table>
bash, image-processing, imagemagick

Bash

Reduce quality of images and rename then 000/xxx

1
2
3
4
5
6
if [[ !-d "reduced" ]]; then
  mkdir "reduced";
fi

b=0
for i in `ls -v`; do convert -quality 50 $i reduced/`printf %03d $b`.jpg; ((b++)); done
https://snipt.net/embed/da6528c56ed333f18d12885b8d09d424/
https://snipt.net/raw/da6528c56ed333f18d12885b8d09d424/
da6528c56ed333f18d12885b8d09d424
bash
Bash
6
2016-10-01T05:56:53
True
False
False
/api/public/snipt/40351/
reduce-quality-of-images-and-rename-then-000xxx
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">if</span> <span class="o">[[</span> !-d <span class="s2">&quot;reduced&quot;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span> </span><span id="L-2"><a name="L-2"></a> mkdir <span class="s2">&quot;reduced&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">fi</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="nv">b</span><span class="o">=</span>0 </span><span id="L-6"><a name="L-6"></a><span class="k">for</span> i in <span class="sb">`</span>ls -v<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> convert -quality <span class="m">50</span> <span class="nv">$i</span> reduced/<span class="sb">`</span><span class="nb">printf</span> %03d <span class="nv">$b</span><span class="sb">`</span>.jpg<span class="p">;</span> <span class="o">((</span>b++<span class="o">))</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, image, imagemagick, reduce

Bash

Convert jpg to lower quality in reduced/ folder

1
2
3
4
if [[ !-d "reduced" ]]; then
  mkdir "reduced";
fi
for i in `ls`; do convert -quality 50 $i reduced/$i; done
https://snipt.net/embed/a650c7a9ef79ccf42346a7e591fd9377/
https://snipt.net/raw/a650c7a9ef79ccf42346a7e591fd9377/
a650c7a9ef79ccf42346a7e591fd9377
bash
Bash
4
2016-10-01T05:56:25
True
False
False
/api/public/snipt/39168/
convert-jpg-to-lower-quality-in-reduced-folder
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">if</span> <span class="o">[[</span> !-d <span class="s2">&quot;reduced&quot;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span> </span><span id="L-2"><a name="L-2"></a> mkdir <span class="s2">&quot;reduced&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">fi</span> </span><span id="L-4"><a name="L-4"></a><span class="k">for</span> i in <span class="sb">`</span>ls<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> convert -quality <span class="m">50</span> <span class="nv">$i</span> reduced/<span class="nv">$i</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, imagemagick, quality, reduce
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.