<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Albert Einshutoin</title>
    <description>The latest articles on DEV Community by Albert Einshutoin (@alberteinshutoin).</description>
    <link>https://dev.to/alberteinshutoin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3682651%2Ff1b604fc-6e5a-43f1-9345-c085c6d400a2.png</url>
      <title>DEV Community: Albert Einshutoin</title>
      <link>https://dev.to/alberteinshutoin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alberteinshutoin"/>
    <language>en</language>
    <item>
      <title>Stop Hardcoding Security Headers: Automate Your CDN Security with YAML</title>
      <dc:creator>Albert Einshutoin</dc:creator>
      <pubDate>Sun, 08 Feb 2026 19:44:22 +0000</pubDate>
      <link>https://dev.to/alberteinshutoin/stop-hardcoding-security-headers-automate-your-cdn-security-with-yaml-44h6</link>
      <guid>https://dev.to/alberteinshutoin/stop-hardcoding-security-headers-automate-your-cdn-security-with-yaml-44h6</guid>
      <description>&lt;p&gt;Have you ever deployed a CloudFront Function or a Cloudflare Worker just to add a few security headers, only to break production because of a syntax error? Or worse, realized that your WAF rules and your application logic were completely out of sync?&lt;/p&gt;

&lt;p&gt;I built cdn-security-framework to solve exactly this problem.&lt;/p&gt;

&lt;p&gt;It’s an open-source CLI compiler that treats your CDN security policy as a single YAML file and automatically generates the necessary edge code (JS/TS) and infrastructure config (Terraform JSON).&lt;/p&gt;

&lt;p&gt;Here is how it works.&lt;/p&gt;

&lt;p&gt;The Problem: "Manual Sync" is a Bug&lt;br&gt;
Usually, securing a CDN involves touching three different places:&lt;/p&gt;

&lt;p&gt;Infrastructure: Configuring WAF rules (Terraform/Console).&lt;/p&gt;

&lt;p&gt;Edge Logic: Writing JavaScript for viewer-request to filter headers or normalize URLs.&lt;/p&gt;

&lt;p&gt;Application: Setting security headers like HSTS or CSP.&lt;/p&gt;

&lt;p&gt;If you update one and forget the others, you create vulnerabilities. If you try to switch from AWS CloudFront to Cloudflare, you have to rewrite everything from scratch.&lt;/p&gt;

&lt;p&gt;The Solution: Define Once, Compile Anywhere&lt;br&gt;
Instead of writing code, you define a security.yml.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# policy/security.yml&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="na"&gt;project&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-secure-app&lt;/span&gt;

&lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# Block non-standard methods&lt;/span&gt;
  &lt;span class="na"&gt;allow_methods&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POST"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HEAD"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;

  &lt;span class="c1"&gt;# Block bad bots by User-Agent&lt;/span&gt;
  &lt;span class="na"&gt;block&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;ua_contains&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sqlmap"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nikto"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;response_headers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# Inject security headers automatically&lt;/span&gt;
  &lt;span class="na"&gt;hsts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max-age=31536000;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;includeSubDomains"&lt;/span&gt;
  &lt;span class="na"&gt;x_content_type_options&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nosniff"&lt;/span&gt;

&lt;span class="na"&gt;firewall&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# Generate WAF rate-limiting rules&lt;/span&gt;
  &lt;span class="na"&gt;rate_limit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you run the compiler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx cdn-security build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tool automatically generates:&lt;/p&gt;

&lt;p&gt;✅ Edge Code: Optimized JavaScript for CloudFront Functions (or TypeScript for Cloudflare Workers).&lt;/p&gt;

&lt;p&gt;✅ WAF Rules: A Terraform-compatible JSON file defining rate limits and blocking rules.&lt;/p&gt;

&lt;p&gt;Quick Start Tutorial&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installation
Install the framework as a dev dependency in your project.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; cdn-security-framework
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initialization
Run the interactive init command. It will ask you about your platform (AWS/Cloudflare) and preferred security level (Strict/Balanced/Permissive).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx cdn-security init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a policy/security.yml file tailored to your needs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build &amp;amp; Deploy
Compile your policy:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx cdn-security build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now take a look at dist/.&lt;/p&gt;

&lt;p&gt;dist/edge/viewer-request.js: Contains the logic to block methods, filter User-Agents, and normalize requests. It handles all the edge cases for you.&lt;/p&gt;

&lt;p&gt;dist/infra/waf-rules.tf.json: Contains the WAF rule definitions.&lt;/p&gt;

&lt;p&gt;If you are using Terraform, you can simply import the generated WAF rules into your existing infrastructure without "taking over" your entire state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="c1"&gt;# main.tf&lt;/span&gt;
&lt;span class="k"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_wafv2_web_acl"&lt;/span&gt; &lt;span class="s2"&gt;"main"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"my-waf"&lt;/span&gt;
  &lt;span class="c1"&gt;# ... other config ...&lt;/span&gt;

  &lt;span class="c1"&gt;# Import the generated rule group&lt;/span&gt;
  &lt;span class="nx"&gt;rule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Imported-CDN-Security-Rules"&lt;/span&gt;
    &lt;span class="nx"&gt;priority&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
    &lt;span class="nx"&gt;statement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;rule_group_reference_statement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;arn&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_wafv2_rule_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;generated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;override_action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;none&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why I built this (and why you should use it)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drift Detection
The tool includes a script to check if your generated code matches your YAML policy. You can run this in your CI/CD pipeline to prevent "shadow edits" to the generated files.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/ci.yml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx cdn-security build&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;git diff --exit-code dist/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Polyglot Security&lt;br&gt;
The same YAML policy can compile to AWS CloudFront Functions (JS) today, and Cloudflare Workers (TS) tomorrow. It abstracts away the runtime differences (e.g., crypto.subtle vs AWS restrictions) so you don't have to be an expert in every platform's quirks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IaC Friendly&lt;br&gt;
It doesn't try to apply changes to your cloud provider directly. It generates artifacts (code and JSON) that your existing deployment tools (Terraform, CDK, Serverless) can consume. This makes it safe to introduce into mature projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Give it a try!&lt;br&gt;
I’d love to hear your feedback. Does this schema cover your security use cases? What features are missing?&lt;/p&gt;

&lt;p&gt;NPM: &lt;a href="https://www.npmjs.com/package/cdn-security-framework" rel="noopener noreferrer"&gt;cdn-security-framework&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/albert-einshutoin/cdn-security-framework" rel="noopener noreferrer"&gt;Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stop writing boilerplate security code by hand. Let the compiler do it.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
      <category>aws</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I built a Node.js image engine in Rust to fix Sharp's deployment headaches</title>
      <dc:creator>Albert Einshutoin</dc:creator>
      <pubDate>Sun, 28 Dec 2025 12:30:14 +0000</pubDate>
      <link>https://dev.to/alberteinshutoin/i-built-a-nodejs-image-engine-in-rust-to-fix-sharps-deployment-headaches-2o61</link>
      <guid>https://dev.to/alberteinshutoin/i-built-a-nodejs-image-engine-in-rust-to-fix-sharps-deployment-headaches-2o61</guid>
      <description>&lt;h1&gt;
  
  
  The "Dependency Hell" of Image Processing
&lt;/h1&gt;

&lt;p&gt;If you've ever deployed a Node.js app that uses &lt;code&gt;sharp&lt;/code&gt; to AWS Lambda or Alpine Linux, you know the pain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Error: 'vips/vips8' not found"&lt;/em&gt;&lt;br&gt;
&lt;em&gt;"Error: libvips.so.42: cannot open shared object file"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;sharp&lt;/code&gt; is an incredible library—it's fast and the industry standard. But it relies on &lt;code&gt;libvips&lt;/code&gt;, a C++ library that often requires complex OS-level dependencies (&lt;code&gt;apt-get install&lt;/code&gt;, dynamic linking, etc.). This makes "Write once, run anywhere" feel like a lie when you move from macOS to Linux production environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, I decided to fix it using Rust.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet lazy-image 🦀
&lt;/h2&gt;

&lt;p&gt;I built &lt;strong&gt;&lt;a href="https://github.com/albert-einshutoin/lazy-image" rel="noopener noreferrer"&gt;lazy-image&lt;/a&gt;&lt;/strong&gt;, a next-generation image processing engine for Node.js.&lt;/p&gt;

&lt;p&gt;It is powered by &lt;strong&gt;Rust&lt;/strong&gt; (via NAPI-RS) and uses statically linked binaries. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero System Dependencies&lt;/strong&gt;: No &lt;code&gt;libvips&lt;/code&gt; installation needed. No &lt;code&gt;apt-get&lt;/code&gt;. No &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt;. Just &lt;code&gt;npm install&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Safety&lt;/strong&gt;: The core logic is written in Rust, protecting your server from memory corruption bugs common in C/C++ libraries when processing user uploads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smaller Binaries&lt;/strong&gt;: Instead of downloading a massive dependency chain, it uses platform-specific packages (~6-9MB).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Performance: Is it actually fast?
&lt;/h2&gt;

&lt;p&gt;Yes. In fact, for many web-optimization tasks, it beats the competition.&lt;/p&gt;

&lt;p&gt;Here is a benchmark result comparing &lt;code&gt;lazy-image&lt;/code&gt; vs &lt;code&gt;sharp&lt;/code&gt; (using mozjpeg + libvips):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;lazy-image&lt;/th&gt;
&lt;th&gt;sharp&lt;/th&gt;
&lt;th&gt;Difference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;JPEG Size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;15,790 bytes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;17,495 bytes&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;-9.7% Smaller&lt;/strong&gt; ✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pipeline Speed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;193ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;273ms&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1.41x Faster&lt;/strong&gt; ⚡&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PNG → AVIF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4,773ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;11,652ms&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;2.44x Faster&lt;/strong&gt; ⚡&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(Tested with 66MB PNG input, resized to 800px)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is it smaller?
&lt;/h3&gt;

&lt;p&gt;I integrated &lt;strong&gt;mozjpeg&lt;/strong&gt; by default, which uses advanced trellis quantization and scan optimization to shave off file size without losing visual quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is it faster?
&lt;/h3&gt;

&lt;p&gt;For format conversions (like PNG to WebP) without resizing, &lt;code&gt;lazy-image&lt;/code&gt; uses a &lt;strong&gt;Copy-on-Write (CoW)&lt;/strong&gt; architecture. It avoids intermediate buffer allocations, making it significantly more memory-efficient and faster for batch processing pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;p&gt;It's designed to be a drop-in replacement for your current workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @alberteinshutoin/lazy-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basic Usage&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ImageEngine&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@alberteinshutoin/lazy-image&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Memory-Efficient: Reads directly from file (bypassing Node.js heap)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ImageEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;// Resize to 800px width (auto height)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;// Rotate&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;grayscale&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;       &lt;span class="c1"&gt;// Apply filter&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output.jpg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jpeg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Batch Processing&lt;br&gt;
You can even process multiple images in parallel with a single engine definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ImageEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;template.jpg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;webp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Uses all CPU cores by default&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processBatch&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img1.jpg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img2.jpg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./output&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;webp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Give it a try!&lt;br&gt;
I built lazy-image to solve my own deployment headaches, but I think it can help many of you who are tired of wrestling with C++ dependencies in Node.js.&lt;/p&gt;

&lt;p&gt;It supports JPEG, PNG, WebP, and AVIF.&lt;/p&gt;

&lt;p&gt;Check it out on GitHub, and let me know what you think! I'm looking for feedback on the Rust/NAPI implementation.&lt;/p&gt;

&lt;p&gt;👉 GitHub: &lt;a href="https://github.com/albert-einshutoin/lazy-image" rel="noopener noreferrer"&gt;https://github.com/albert-einshutoin/lazy-image&lt;/a&gt;&lt;br&gt;
📦 npm: &lt;a href="https://www.npmjs.com/package/@alberteinshutoin/lazy-image" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@alberteinshutoin/lazy-image&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  node #rust #javascript #webdev
&lt;/h1&gt;

</description>
      <category>rust</category>
      <category>showdev</category>
      <category>devops</category>
      <category>node</category>
    </item>
  </channel>
</rss>
