ss
Navigate back to the homepage

Spaceout

Interstellar design

UX/UI design, Web and Native App develeopement.

about meHow it's doneContact
Link to $https://www.facebook.com/spaceout/Link to $https://twitter.com/spaceoutLink to $https://www.instagram.com/spaceout/Link to $https://blog.spaceout.pl/Link to $https://dribbble.com/spaceoutLink to $https://behance.com/spaceoutLink to $https://github.com/massivDash/

Imagermachine

by
Luke Celitan
category: project, reading time: 2 min
Version Documentation License: MIT Twitter: spaceoutPL

Introduction

In recent times I have decided to start learing a new programming language. Out of all the possibilities I have found Rust to be the most suitable. Rust is a safe, fast, and memory safe language for writing software, I see a lot of potential in Rust esspeciall in building software for future IoT devices. Rust is also a heavily typed proggraming language which makes it easy to write code that is more readable and easy to debug.

I have embarked on a mission to build something useful with it, the idea for rewritting my previous optimization intercative cli build with typescript to rust came as an obvious choice for me.

Cargo-imagermachine

Rust cli for batch optimizing images

Cargo-imagermachine was designed as a subtool of cargo package manger, so user can run the interactive cli from the command line inside folders that contain pictures.

Imagermachine uses turbo-jpeg library for jpeg files optimization and oxi png for png images. You must install the turbo-jpeg yourself as the cli uses only the bindings to the turbo-jpeg library. Installation guide for respective systems below.

Imagermachine can:

  • Optimize png and jpg images.
  • Resize and crop images.
  • Rename the transformed files based on providedname(index).ext
  • Convert files to Webp
  • todo: set optimalisation custom config

Dependencies

So far the cli has been tested on unix systems (Debian, Mac).
Before using cargo-imagermachine you must install

Rust

Follow the official guideline for installing rust on your system https://www.rust-lang.org/tools/install

Libturbojpeg

Offical webiste and documentation 👉 https://www.libjpeg-turbo.org/

Debian

1sudo apt-get install libturbojpeg libturbojpeg0-dev

This should be enough to get started on Ubuntu

Mac

1brew install jpeg-turbo

! Remember to copy all the export paths that brew will print out after installation, I am using the following config in the cargo.toml file, pkg-config (also via brew) installation is needed for this setup to work.

1turbojpeg = {version = "0.4", features = ["image", "pkg-config"]}

If you have troubles linking the cli to your libturbo, you can try to edit the cargo.toml file and add feature flags into turbojpeg features array, for more reference follow this link.

Screenshot of cargo-imagermachine

Install

In order to install cargo-imagermachine on your computer, clone the project then run the following command from the project folder:

1cargo install --path .

Usage

If you followed the offical rust documentation and cargo / rustc is in scope, navigate to a input folder and run

1cargo imagermachine

Follow directions on the interactive cli to optimize, resize, rename the images.

Show your support

Give a ⭐️ if this project helped you!

s