Skip to content

nguyencse/rustlib_compress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rustlib_compress

Image compress using Rust

This is a fork of Pio to adapt multiple platforms, not even CLI or desktop.
Big thanks.

Features

  • Optimize images automatically for the app, web.
  • Supports PNG, JPEG and WebP
  • Ensure images are displayed consistently across browsers by handling ICC profiles and Exif orientation
  • Powered by great projects like mozjpeg and pngquant
  • Easily installable statically-linked binary (for Android, iOS, Flutter, React Native, web apps, desktop apps, and even terminal CLI).

Let's contribute, folks.

Installation

iOS

Build from source

cargo install cargo-lipo

then

cargo lipo --release

to generate a bundle named libcomp.a for iOS and use this bundle to integrate with your apps.
Or can use latest bundle file from releases

Linux & macOS

Download the latest Linux & macOS binary from releases. These versions are built on Ubuntu 22.04.3 LTS and macOS Sonoma 14.0

After downloading the binary, run chmod +x path-to-comp to make it executable.
Consider storing the binary somewhere on your PATH like /usr/local/bin/comp.

Copy downloaded binary to local bin:

sudo cp path-to-comp /usr/local/bin/comp

Make binary excutable:

sudo chmod +x /usr/local/bin/comp

Usage

Flutter

Checkout this repository Rust Image Compress Flutter Example

CLI

comp input.jpeg --output output.jpeg

The target quality can be set using --quality option:

comp input.jpeg --quality 95 --output output.jpeg

The target quality is a value between 0 and 100 and roughly corresponds to JPEG quality values.

For the full list of available options, run

comp --help

About

Image compress using Rust

Resources

License

Stars

Watchers

Forks

Languages