diff options
author | bt <bt@btxx.org> | 2024-06-08 13:22:19 -0400 |
---|---|---|
committer | bt <bt@btxx.org> | 2024-06-08 13:22:19 -0400 |
commit | dcfb172704f3afb68a30425029ec834be2883274 (patch) | |
tree | 02ac480745db802d7af03f3213a0c568322170e3 /build/batch-webp-conversion/index.html | |
parent | e146f8a64c793c337999ce316b16ebe5fe6f2dab (diff) |
More content porting, on-going markdown changes for lowdown support
Diffstat (limited to 'build/batch-webp-conversion/index.html')
-rw-r--r-- | build/batch-webp-conversion/index.html | 104 |
1 files changed, 63 insertions, 41 deletions
diff --git a/build/batch-webp-conversion/index.html b/build/batch-webp-conversion/index.html index a9ce6e2..839973d 100644 --- a/build/batch-webp-conversion/index.html +++ b/build/batch-webp-conversion/index.html @@ -1,68 +1,90 @@ <!doctype html> -<html lang="en" id="top"> +<html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" href="data:,"> <title>Batch Converting Images to webp with macOS Automator</title> - <link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" /> - <style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style> + <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" /> + <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" /> +<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style> </head> <nav> - <a href="#menu">Menu ↓</a> + <a href="#menu">Menu ↓</a> </nav> <main> -<h1>Batch Converting Images to webp with macOS Automator</h1> +<h1 id="batch-converting-images-to-webp-with-macos-automator">Batch Converting Images to webp with macOS Automator</h1> + <p>2021-10-15</p> -<p>A great deal of my time working as a web/UI designer is spent exporting and/or converting images for software products and websites. Although a lot of modern applications can render image conversions at build time, a custom conversion is sometimes requested for an image to be set as <code>webp</code>.</p> -<p>You <em>could</em> download one of the many native apps from the Mac App Store to do this for you - but why not create your own script and run it with a simple right-click directly inside Finder? <strong>Let's do just that!</strong></p> -<h2>Basic requirements</h2> + +<p>A great deal of my time working as a web/UI designer is spent exporting and/or converting images for software products and websites. Although a lot of modern applications can render image conversions at build time, a custom conversion is sometimes requested for an image to be set as <code>webp</code>.</p> + +<p>You <em>could</em> download one of the many native apps from the Mac App Store to do this for you - but why not create your own script and run it with a simple right-click directly inside Finder? <strong>Let’s do just that!</strong></p> + +<h2 id="basic-requirements">Basic requirements</h2> + <p><strong>Important!</strong>: As of this time of writing, the official <code>libwebp</code> package release is <em>libwebp-1.2.1-mac-10.15</em>. If this has been updated since then, change the command below to match that of the proper release version.</p> -<p>1) First you will need to download the <code>libwebp</code> package to your Downloads folder: <a href="https://developers.google.com/speed/webp/download">developers.google.com/speed/webp/download</a> - - <em>Look for the "Download for macOS link"</em></p> -<p>2) Next we will need to copy the <code>cwebp</code> folder to our <code>/usr/local/bin</code> directory: - - Open macOS Terminal - - Run <code>sudo cp /Downloads/libwebp-1.2.1-mac-10.15/bin/cwebp /usr/local/bin</code> - - <em>Note:</em> if the <code>/usr/local/bin</code> directory doesn't exist, simply create it by running: <code>sudo cd /usr/local && mkdir bin</code></p> -<h2>Creating our custom Automator script</h2> -<p>1) Open the macOS Automator from the Applications folder</p> -<p>2) Select <code>Quick Option</code> from the first prompt</p> -<p>3) Set "Workflow receives current" to <code>image files</code></p> -<p>4) Set the label "in" to <code>Finder</code></p> -<p>5) From the left pane, select "Library > Utilities"</p> -<p>6) From the presented choices in the next pane, drag and drop <code>Run Shell Script</code> into the far right pane</p> -<p>7) Set the area "Pass input" to <code>as arguments</code></p> -<p>8) Enter the following code below as your script and type <code>⌘-S</code> to save (name it something like "Convert to webp")</p> -<pre><code>for f in "$@" + +<ol> +<li><p>First you will need to download the <code>libwebp</code> package to your Downloads folder: <a href="https://developers.google.com/speed/webp/download">developers.google.com/speed/webp/download</a> </p> + +<ul> +<li><em>Look for the “Download for macOS link”</em></li> +</ul></li> +<li><p>Next we will need to copy the <code>cwebp</code> folder to our <code>/usr/local/bin</code> directory:</p> + +<ul> +<li>Open macOS Terminal</li> +<li>Run <code>sudo cp /Downloads/libwebp-1.2.1-mac-10.15/bin/cwebp /usr/local/bin</code></li> +<li><em>Note:</em> if the <code>/usr/local/bin</code> directory doesn’t exist, simply create it by running: <code>sudo cd /usr/local && mkdir bin</code></li> +</ul></li> +</ol> + +<h2 id="creating-our-custom-automator-script">Creating our custom Automator script</h2> + +<ol> +<li><p>Open the macOS Automator from the Applications folder</p></li> +<li><p>Select <code>Quick Option</code> from the first prompt</p></li> +<li><p>Set “Workflow receives current” to <code>image files</code></p></li> +<li><p>Set the label “in” to <code>Finder</code></p></li> +<li><p>From the left pane, select “Library > Utilities”</p></li> +<li><p>From the presented choices in the next pane, drag and drop <code>Run Shell Script</code> into the far right pane</p></li> +<li><p>Set the area “Pass input” to <code>as arguments</code></p></li> +<li><p>Enter the following code below as your script and type <code>⌘-S</code> to save (name it something like “Convert to webp”)</p> + +<p>for f in “$@” do -/usr/local/bin/cwebp -q 85 "$f" -o "${f%.*}.webp" -done -</code></pre> +/usr/local/bin/cwebp -q 85 “$f” -o “${f%.*}.webp” +done</p></li> +</ol> + <p>For visual reference, it should look something like this:</p> -<p><figure> -<img src="/public/images/automator.png" alt="macOS Automator"> -<figcaption>(<a href="/public/images/automator.webp">link to hi-res image</a>)</figcaption> -</figure></p> + <p>And when right-clicking an image file in the Finder window, it should now give you the option to convert:</p> -<p><figure> -<img src="/public/images/automator-2.png" alt="Right click to convert"> -<figcaption>(<a href="/public/images/automator-2.webp">link to hi-res image</a>)</figcaption> -</figure></p> -<h2>Making edits to your script</h2> -<p>If you ever have the need to edit this script (for example, changing the default <code>85</code> quality parameter), you will need to navigate to your <code>~/Library/Services</code> folder and open your custom webp Quick Action in the Automator application. </p> + +<h2 id="making-edits-to-your-script">Making edits to your script</h2> + +<p>If you ever have the need to edit this script (for example, changing the default <code>85</code> quality parameter), you will need to navigate to your <code>~/Library/Services</code> folder and open your custom webp Quick Action in the Automator application. </p> + <p>Simple as that!</p> -<h2>Possible Hiccups</h2> + +<h2 id="possible-hiccups">Possible Hiccups</h2> + <p>I was contacted by the very helpful <a href="https://kevq.uk">Kev Quirk</a> about a minor problem he encountered while following this tutorial. When trying to run <code>cwebp</code> he received the following error message:</p> -<pre><code>cwebp cannot be opened because it's from an unverified developer + +<pre><code>cwebp cannot be opened because it's from an unverified developer </code></pre> + <p>Doing the next steps seemed to have fixed this issue for him:</p> + <ol> -<li>Click on the "Open in Finder" in the error message prompt</li> +<li>Click on the “Open in Finder” in the error message prompt</li> <li>Double-click on the <code>cwebp</code> utility to open in Terminal</li> -<li>You'll then be prompted with a pop-up asking if you wish to execute</li> +<li>You’ll then be prompted with a pop-up asking if you wish to execute</li> </ol> + <p>After following these steps, the issue should be resolved.</p> <footer role="contentinfo"> <h2>Menu Navigation</h2> |