snipt

Ctrl+h for KB shortcuts

JavaScript

Test if href points image

1
2
3
4
if($(this).attr('href').indexOf('.jpg') > 0) // or any other extension
{
    //do what you want
}
https://snipt.net/embed/6b6e76de0f8d48d7e980f025b5f0f153/
https://snipt.net/raw/6b6e76de0f8d48d7e980f025b5f0f153/
6b6e76de0f8d48d7e980f025b5f0f153
js
JavaScript
4
2016-09-29T18:17:09
True
False
False
Mar 17, 2014 at 01:11 PM
/api/public/snipt/122560/
test-if-href-points-image
<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="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;.jpg&#39;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// or any other extension</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">//do what you want</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
check, href, image, img, javascript, jpeg, jpg, jquery, js, test

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-09-29T14:53:10
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

Resize many JPEG images for Facebook usage

1
2
3
4
5
6
7
#!/bin/bash

# On Facebook, maximum size per image side is 720 pixels.

mkdir Facebook

for i in *.jpg; do convert $i -quality 100 -resize 720x720 Facebook/$i; done
https://snipt.net/embed/c3a8f1da3f8f9bba7cd384214fcfeeba/
https://snipt.net/raw/c3a8f1da3f8f9bba7cd384214fcfeeba/
c3a8f1da3f8f9bba7cd384214fcfeeba
bash
Bash
7
2016-09-29T16:40:49
True
False
False
/api/public/snipt/23367/
resize-many-jpeg-images-for-facebook-usage
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c"># On Facebook, maximum size per image side is 720 pixels.</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>mkdir Facebook </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="k">for</span> i in *.jpg<span class="p">;</span> <span class="k">do</span> convert <span class="nv">$i</span> -quality <span class="m">100</span> -resize 720x720 Facebook/<span class="nv">$i</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, facebook, images, jpeg, jpg, resize

Bash

Convert Canon CR2 raw images to JPEG images

1
2
3
4
#!/bin/bash

# for i in *.cr2; do dcraw -c -q 0 -w -H 5 -b 8 $i | cjpeg -quality 100 > $i.jpg; done
for i in *.CR2; do dcraw -c -q 3 -a -w -H 5 -b 5 $i | cjpeg -quality 100 > $i.jpg; done
https://snipt.net/embed/81f79fbece30c8e7d66abbcd45e830e6/
https://snipt.net/raw/81f79fbece30c8e7d66abbcd45e830e6/
81f79fbece30c8e7d66abbcd45e830e6
bash
Bash
4
2016-09-29T10:16:54
True
False
False
/api/public/snipt/22706/
convert-canon-cr2-raw-images-to-jpeg-images
<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="c">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c"># for i in *.cr2; do dcraw -c -q 0 -w -H 5 -b 8 $i | cjpeg -quality 100 &gt; $i.jpg; done</span> </span><span id="L-4"><a name="L-4"></a><span class="k">for</span> i in *.CR2<span class="p">;</span> <span class="k">do</span> dcraw -c -q <span class="m">3</span> -a -w -H <span class="m">5</span> -b <span class="m">5</span> <span class="nv">$i</span> <span class="p">|</span> cjpeg -quality <span class="m">100</span> &gt; <span class="nv">$i</span>.jpg<span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, canon, convert, cr2, images, jpeg, jpg, raw
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.