<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dimitri Nicolas on Medium]]></title>
        <description><![CDATA[Stories by Dimitri Nicolas on Medium]]></description>
        <link>https://medium.com/@dnicolas?source=rss-21d51a08c48e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sYJGHNAtp8t8wMZzTIsnfQ@2x.jpeg</url>
            <title>Stories by Dimitri Nicolas on Medium</title>
            <link>https://medium.com/@dnicolas?source=rss-21d51a08c48e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:09:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dnicolas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Learn How to Automate your Image Optimization Process with Lepto]]></title>
            <link>https://medium.com/@dnicolas/learn-how-to-automate-your-images-optimization-process-with-lepto-ad2cf89e2a31?source=rss-21d51a08c48e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad2cf89e2a31</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Dimitri Nicolas]]></dc:creator>
            <pubDate>Sun, 05 Aug 2018 17:40:44 GMT</pubDate>
            <atom:updated>2018-08-13T22:25:49.484Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TjMIYRrt6mwSBrJc" /><figcaption>Photo by <a href="https://unsplash.com/@patrykgradyscom?utm_source=medium&amp;utm_medium=referral">Patryk Grądys</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Optimizing images is a long duty, maybe you’re already using imagemin or ImageOptim, they’re great tools, but it can seem difficult to automate their usage.</p><p>When you want to optimize your images for the web, you have plenty of tasks to do like:</p><ul><li>Resizing</li><li>Creating different resolution files (for Retina screens)</li><li>Optimizing (removing metadata)</li><li>Compressing</li><li>Create better format alternatives (like WebP)</li></ul><p>We’re already compiling our JavaScript and CSS through module bundlers and pre/post-processors, here comes a new build step: image processing.</p><h3>Getting started with Lepto</h3><p><a href="https://github.com/leptojs/lepto">github.com/leptojs/lepto</a></p><p>Lepto is a Node.js module and Command Line Interface responsible for <strong>editing, optimizing and analyzing</strong> images resources. So let’s get started!</p><p>First of all, you will <strong>need to have an “npm initialized project”</strong>. If not, run the command npm init.</p><p>You will also need to install the CLI tool as a dev dependency:</p><pre>$ npm install -D lepto-cli</pre><p>If you’re <strong>too lazy to collect some ordinary images</strong>, I give you some that <a href="https://gist.github.com/dimitrinicolas/766eecec10adf4deb6a20c8002df4f2b">you can download on this gist</a>, simply click on the “Download ZIP” button and put those resources into an “assets” directory.</p><p>Then you have to create your configuration file named lepto.config.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1f174bc1034cfa146fb84aaf1684c3a/href">https://medium.com/media/e1f174bc1034cfa146fb84aaf1684c3a/href</a></iframe><p>Create a new npm script named like build into your package.json:</p><pre>{<br>  ...<br>  &quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;lepto&quot;,<br>    ...<br>  }<br>  ...<br>}</pre><p>Now, by running the command npm run build, Lepto will compress all jpg and png from your “assets” directory and export them into the output directory. By setting the watch option to true, Lepto will watch for every single change inside the “assets” directory to relaunch the process.</p><p>By default, Lepto comes with zero configuration, so you need to <strong>write a list of </strong><strong>filters</strong> each of them associated with a glob and a list of plugins to use. In this configuration file example, we ask Lepto to compress all jpg and png files with a quality of 75.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mL7lIXfkeI5YKjjjNKNdzg.png" /><figcaption>lepto command running</figcaption></figure><h3>Let’s add some plugins</h3><p>Now, you would like to resize your images. There is a plugin for that: <a href="https://github.com/leptojs/lepto-resize">lepto-resize</a>, you will have to install it like that:</p><pre>$ npm install -D lepto-resize</pre><h4>Then we’ll add a new filter in our Lepto config:</h4><pre>{<br>  &quot;glob&quot;: &quot;**/*.{jpg,jpeg}&quot;,<br>  &quot;use&quot;: [<br>    {<br>      &quot;name&quot;: &quot;lepto-resize&quot;,<br>      &quot;maxWidth&quot;: 1200<br>    }<br>  ]<br>}</pre><p>All your jpgs have now a width less or equal to 1200px. You can discover way more options to use with <a href="https://github.com/leptojs/lepto-resize">lepto-resize</a> on the repository: <a href="https://github.com/leptojs/lepto-resize">github.com/leptojs/lepto-resize</a>.</p><h4>Let’s add another filter to create Retina’s versions of our png:</h4><pre>{<br>  &quot;glob&quot;: &quot;**/*.png&quot;,<br>  &quot;use&quot;: [<br>    {<br>      &quot;name&quot;: &quot;lepto-resize&quot;,<br>      &quot;retina&quot;: [2, 3]<br>    }<br>  ]<br>}</pre><p>Now we can easily insert them into our html using srcset:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c1ff9b547bb4a087108f9794457e12e/href">https://medium.com/media/9c1ff9b547bb4a087108f9794457e12e/href</a></iframe><p>I’m pretty sure that you are now capable of adding the plugin <a href="https://github.com/leptojs/lepto-webp">lepto-webp</a> to create WebP alternatives of your jpgs! Check out the documentation here: <a href="https://github.com/leptojs/lepto-webp">github.com/leptojs/lepto-webp</a>.</p><h3>Using the GUI</h3><p>For having the best-optimized images, we also need to carefully choose the best suitable quality percentage for each of them.</p><p>By default, the GUI is accessible on the port 4490, so let’s run npm run build and go on <a href="http://localhost:4490/">localhost:4490</a>. We’ll get this beautiful interface composed of three parts: your input files list, your filters list and finally the optimizer waiting for a file selection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFVpKsd3osyJIcg3ZtOu-g.png" /><figcaption>Lepto Graphical User Interface</figcaption></figure><p>So let’s select a file in the list: it is now displayed it the optimizer, letting us play with the quality slider and see the output in real-time. When you’re satisfied with a quality percentage, <strong>click on the button “Add optimization plugin”</strong> and <strong>save this new configuration by clicking on “Save config” </strong>(or press ⌘S / Ctrl+S).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S557h_tOhy3juCI5AK3V9g.png" /><figcaption>Lepto GUI optimizer usage</figcaption></figure><p>By adding an “optimization plugin” the GUI is simply creating a new filter with a glob equal to the file name, and the plugin corresponding to the file extension:</p><pre>{<br>  &quot;glob&quot;: &quot;001.jpg&quot;,<br>  &quot;use&quot;: [<br>    {<br>      &quot;name&quot;: &quot;lepto.jpeg&quot;,<br>      &quot;quality&quot;: 48<br>    }<br>  ]<br>}</pre><p>Be sure to keep those specific filters at the end of the list.</p><h3>To go even further</h3><p>The use cases for this tool are endless. You can even <strong>automatically collect the vibrant colors of your images</strong> and get them into a single JSON file with the <a href="https://github.com/leptojs/lepto-vibrant-color">lepto-vibrant-color</a> plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEkCyCHzcNT9InTtqBc0zw.png" /><figcaption>lepto-vibrant-color extraction example</figcaption></figure><p>To learn more about Lepto, check out the lepto and lepto-cli documentations:</p><ul><li><a href="https://github.com/leptojs/lepto">github.com/leptojs/lepto</a></li><li><a href="https://github.com/leptojs/lepto-cli">github.com/leptojs/lepto-cli</a></li></ul><p>To learn even more about the best image optimization practices I recommend you the “<a href="https://images.guide/">Essential Image Optimization</a>” guide by <a href="https://twitter.com/addyosmani">Addy Osmani</a>: <a href="https://images.guide/">images.guide</a>.</p><h3>About me</h3><p>I’m a French student, enthusiast of front-end development for several years now. By creating Lepto, I tried my best to make a non-frustrating and efficient tool to easily manage image optimization. Building a Command Line Interface was obvious for performance and ease of use reason (see <a href="https://brandur.org/interfaces">this great article about Terminal and design</a> by <a href="https://twitter.com/brandur">Brandur</a>). However, the GUI was necessary for choosing the best compression quality. So I came to this great harmony.</p><p>I am listening to all suggestions, discussions and violent criticism via <a href="https://twitter.com/dimitrincls">Twitter</a> or via e-mail: <a href="/service/mailto:dimitri@fivecorp.fr">dimitri@fivecorp.fr</a>.</p><p>Thanks for reading! 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad2cf89e2a31" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>