<?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: fj-dig</title>
    <description>The latest articles on DEV Community by fj-dig (@frr).</description>
    <link>https://dev.to/frr</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%2F623689%2Fe1d3255d-ca0e-4e58-bdac-0ed7769f7c21.png</url>
      <title>DEV Community: fj-dig</title>
      <link>https://dev.to/frr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frr"/>
    <language>en</language>
    <item>
      <title>Open source: ImageKit, a Rust-based tool for batch image compression and watermarking.</title>
      <dc:creator>fj-dig</dc:creator>
      <pubDate>Sat, 28 Jun 2025 09:46:11 +0000</pubDate>
      <link>https://dev.to/frr/open-source-imagekit-a-rust-based-tool-for-batch-image-compression-and-watermarking-2i5</link>
      <guid>https://dev.to/frr/open-source-imagekit-a-rust-based-tool-for-batch-image-compression-and-watermarking-2i5</guid>
      <description>&lt;h2&gt;
  
  
  &lt;a href="https://github.com/hzbd/imagekit" rel="noopener noreferrer"&gt;ImageKit - https://github.com/hzbd/imagekit&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ImageKit&lt;/strong&gt; is a powerful, fast, and flexible command-line tool for batch image processing. Written in Rust, it leverages parallel processing to maximize performance, allowing you to effortlessly resize, control the quality of, and add highly customizable watermarks to entire directories of images.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Batch Processing&lt;/strong&gt;: Recursively processes all images (&lt;code&gt;.jpg&lt;/code&gt;, &lt;code&gt;.jpeg&lt;/code&gt;, &lt;code&gt;.png&lt;/code&gt;, &lt;code&gt;.gif&lt;/code&gt;, &lt;code&gt;.bmp&lt;/code&gt;) in a specified input directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart Scaling&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;If only a width is provided, the height is calculated automatically to maintain the aspect ratio.&lt;/li&gt;
&lt;li&gt;If only a height is provided, the width is calculated automatically.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Quality Control&lt;/strong&gt;: Use the &lt;code&gt;-q&lt;/code&gt; or &lt;code&gt;--quality&lt;/code&gt; flag (1-100) to fine-tune the output quality, balancing file size and visual fidelity. Set to &lt;code&gt;100&lt;/code&gt; for the best possible quality.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Powerful Watermarking&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-language Support&lt;/strong&gt;: Perfectly renders watermarks with mixed text, including &lt;strong&gt;Chinese, Japanese, Korean (CJK)&lt;/strong&gt;, and Latin characters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highly Customizable&lt;/strong&gt;: Add text watermarks in nine standard positions and freely set the font size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Colors&lt;/strong&gt;: Precisely control watermark color and opacity using hex codes (e.g., &lt;code&gt;RRGGBB&lt;/code&gt; or &lt;code&gt;RRGGBBAA&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intelligent Watermark Scaling&lt;/strong&gt;: If the requested watermark is too large for an image, it is automatically scaled down to fit perfectly, ensuring it is never cropped.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;⚡ Blazing Fast Performance&lt;/strong&gt;: Utilizes the &lt;a href="https://github.com/rayon-rs/rayon" rel="noopener noreferrer"&gt;Rayon&lt;/a&gt; library to process images in parallel, taking full advantage of multi-core CPUs.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Cross-Platform&lt;/strong&gt;: Compiles and runs on Windows, macOS, and Linux.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⚙️ Installation &amp;amp; Build
&lt;/h2&gt;

&lt;p&gt;You will need to have &lt;a href="https://www.rust-lang.org/tools/install" rel="noopener noreferrer"&gt;Rust and Cargo&lt;/a&gt; installed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Clone the Repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/hzbd/imagekit.git
&lt;span class="nb"&gt;cd &lt;/span&gt;imagekit
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prepare Fonts&lt;/strong&gt;&lt;br&gt;
This tool uses a font fallback system for multi-language support. Please ensure the &lt;code&gt;assets/&lt;/code&gt; directory contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;Roboto-Regular.ttf&lt;/code&gt; (for Western characters)&lt;/li&gt;
&lt;li&gt;  A font with CJK support, such as &lt;code&gt;SourceHanSansSC-Regular.otf&lt;/code&gt; (Source Han Sans). You can download it from &lt;a href="https://github.com/adobe-fonts/source-han-sans/releases" rel="noopener noreferrer"&gt;Adobe Fonts GitHub&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Build the Project&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo build &lt;span class="nt"&gt;--release&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Locate the Executable&lt;/strong&gt;&lt;br&gt;
After building, the executable will be located in the &lt;code&gt;target/release/&lt;/code&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🚀 Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Example 1: Add a watermark with mixed Chinese and English text
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/imagekit &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-i&lt;/span&gt; ./input_photos &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; ./processed_photos &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--watermark-text&lt;/span&gt; &lt;span class="s2"&gt;"你好, World! - Test Watermark"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example 2: Resize images and save at maximum quality
&lt;/h4&gt;

&lt;p&gt;If you want to resize without quality loss for JPEGs, use &lt;code&gt;--quality 100&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/imagekit &lt;span class="nt"&gt;-i&lt;/span&gt; ./input_photos &lt;span class="nt"&gt;-o&lt;/span&gt; ./processed_photos &lt;span class="nt"&gt;--width&lt;/span&gt; 1024 &lt;span class="nt"&gt;--quality&lt;/span&gt; 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example 3: Add an opaque black watermark (using default quality 85)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/imagekit &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-i&lt;/span&gt; ./input_photos &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; ./processed_photos &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--watermark-text&lt;/span&gt; &lt;span class="s2"&gt;"Confidential"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--watermark-color&lt;/span&gt; 000000FF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📋 Command-Line Options
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Flags&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Required/Optional&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Input Directory&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;-i&lt;/code&gt;, &lt;code&gt;--input-dir&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The source directory containing images to process.&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Required&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output Directory&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;-o&lt;/code&gt;, &lt;code&gt;--output-dir&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The directory where processed images will be saved.&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Required&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Width&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--width&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) Resize image width. Scales proportionally if height is omitted.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;Original width&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Height&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--height&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) Resize image height. Scales proportionally if width is omitted.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;Original height&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watermark Text&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--watermark-text&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) The text content for the watermark.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watermark Position&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--watermark-position&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) The position of the watermark on the image.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;&lt;code&gt;se&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Font Size&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--font-size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) The font size of the watermark text in pixels.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;&lt;code&gt;24&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watermark Color&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--watermark-color&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;(Optional) Watermark color in RRGGBB or RRGGBBAA hex format.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;FFFFFF80&lt;/code&gt; (semi-transparent white)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quality&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;-q&lt;/code&gt;, &lt;code&gt;--quality&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;(Optional) Set output quality (1-100). Affects JPEG and PNG compression.&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;td&gt;&lt;code&gt;85&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Available values for &lt;code&gt;watermark-position&lt;/code&gt;:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;nw&lt;/code&gt;: North-West, &lt;code&gt;north&lt;/code&gt;: North, &lt;code&gt;ne&lt;/code&gt;: North-East&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;west&lt;/code&gt;: West, &lt;code&gt;center&lt;/code&gt;: Center, &lt;code&gt;east&lt;/code&gt;: East&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;sw&lt;/code&gt;: South-West, &lt;code&gt;south&lt;/code&gt;: South, &lt;code&gt;se&lt;/code&gt;: South-East&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🛠️ Development &amp;amp; Testing
&lt;/h2&gt;

&lt;p&gt;If you'd like to contribute to the project:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Clone the repository and prepare the fonts.&lt;/li&gt;
&lt;li&gt; Make your changes.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run tests to ensure all functionality is working as expected:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📜 License
&lt;/h2&gt;

&lt;p&gt;This project is licensed under the &lt;a href="https://dev.toLICENSE"&gt;MIT License&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>imagekit</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
