Skip to content
/ imgc-rs Public

CLI for image conversion written in Rust

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENCE_MIT
Apache-2.0
LICENSE_APACHE
Notifications You must be signed in to change notification settings

tduyng/imgc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Converter (imgc)

Welcome to imgc!

This tool is a command-line utility built with Rust, focusing on converting images into the WebP format. Leveraging the powerful image crate, imgc simplifies the process of batch converting images, optimizing for both performance and storage efficiency.

Key Features

  • Efficient Conversion: Easily convert a variety of image formats to WebP with lossless compression.
  • Broad Format Support: Works with many popular image formats, including PNG and JPEG.
  • Custom Output: Choose where your converted images are saved.
  • Speedy Processing: Takes advantage of rayon for fast, parallel processing.
  • Glob Pattern Support: Since imgc is not yet available on crates.io, you'll need to clone the repository to get started:

Getting Started

Prerequisites

  • Ensure you have the latest stable version of Rust and Cargo installed on your system.

Installation Guide

Since imgc is not yet available on crates.io, you'll need to clone the repository to get started:

  1. Clone the repository:

    git clone https://github.com/tduyng/imgc-rs.git
    cd imgc-rs
  2. Build the project:

    cargo build --release
  3. Install locally

    cargo install --path .
  4. Install from Github

    If you want to test this tool without cloning the repository, you can install it directly from git:

    cargo install --git https://github.com/tduyng/imgc-rs.git

Once installed, you can start using imgc with the command imgc.

  1. Uninstall

    cargo uninstall imgc

How to Use imgc

Basic Usage

Imgc program use glob patterns for easy file handling:

imgc webp "examples/**/*.png"
imgc webp "examples/**/*.jpg"
imgc webp "examples/**/*"

Specifying an output directory

imgc webp "examples/**/*" -o output_images

Cleaning up generated files

Warning: Use this command with caution.

imgc clean "examples/**/*.webp"

Command Help

For detailed command usage, --help or -h will guide you through:

❯ imgc -h              
A CLI for converting images to the WebP format writtent in Rust

Usage: imgc <COMMAND>

Commands:
  webp   Convert images to webp format
  clean  Clean files by given extension
  help   Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

For the webp command:

❯ imgc webp -h                                     
Convert images to webp format

Usage: imgc webp [OPTIONS] <PATTERN>

Arguments:
  <PATTERN>  Glob pattern to match images to convert. Example: `images/**/*.jpg`

Options:
  -o, --output <OUTPUT>  (Optional) Output of processed images. Defaults to the same location as the original images
  -h, --help             Print help

For the clean command:

❯ imgc clean -h                  
Remove files matching a glob pattern

Usage: imgc clean <PATTERN>

Arguments:
  <PATTERN>  Glob pattern to match files to remove

Options:
  -h, --help  Print help

Example Directory Structure

Given the following directory structure:

examples
├── 1.png
├── 1.webp
├── img1
│   ├── 2.png
│   ├── 2.webp
│   └── img11
│       ├── 3.jpg
│       └── 3.webp
├── img2
│   ├── 4.jpeg
│   └── 4.webp

Using imgc, you can convert all supported images to WebP, saving them either in a specified directory or alongside the original files.

Example of webp command:

Webp command example

Example of clean command:

Clean command example

What's Next

  • Testing
  • Introduce advanced options for compression, quality, and resizing
  • Expand support for additional conversion formats

License

Choose between MIT License or Apache License as per your preference.

About

CLI for image conversion written in Rust

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENCE_MIT
Apache-2.0
LICENSE_APACHE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages