jq for images - experimental

Overview


Logo

iq - a little tool for image manipulation

Inspired by `jq`, iq is an experimental tool for manipulating images through expressions which transform pixels.

Usage

iq 0.1.0
[email protected]

USAGE:
    iq [OPTIONS] [ARGS]

ARGS:
    <input_path>     The path to the input image
    <output_path>    Where to write the output image

OPTIONS:
    -b, --blank <dimensions>    Use a blank canvas of provided size 'HxW' (ex. '100x300')
    -e, --expr <expressions>    The expressions to evaluate
    -f, --file <file>           Pass a file containing expressions to run
    -h, --help                  Print help information
    -V, --version               Print version information

Examples

Disclaimer: The tool is a work in progress and in its very early stages. There are certainly bugs and plenty of things to improve.

iq is passed an image and a set of expressions and produces an output image. For example:

iq -e "_ => p(_.y, _.x, _.r, 0, 0)" assets/dalle_logo.png out.jpg

Would produce an output image out.jpg with the green and blue color channels removed.

Logo

Slice Ranges

Expressions can do much more complex actions than simply uniformly changing colors. For example given this DALLE generated image of Philip Seymour Hoffman in the Disney film "Cars":

Logo

We can crop patches of the image using "slice ranges":

# Crop out a circle and replace the outside with a gradient
iq -e "[0:100, 0:100]" \
    assets/examples/dalle_philip_seymour_in_cars_movie.jpg \
    cropped_seymour.jpg
Logo

Match Expressions

We can use match expressions to apply other expressions conditionally

# Change any pixel with a green channel value greater than 128 to white
iq -e "_.g > 128 => p(_.y, _.x, 255, 255, 255) : _" \
    assets/examples/dalle_philip_seymour_in_cars_movie.jpg \
    highlight_mcqueen.jpg
Logo
# Crop out a circle and replace the outside with a gradient
iq -e "
    ([].w/2) >= sqrt(sq(_.x - center().x) + sq(_.y - center().y)) =>
        p(_.y, _.x, _.r, 255 - _.r, _.r) :
        p(_.y, _.x, (_.r * _.y) / [].h, (_.g * _.x) / [].w, 0)
" \
    assets/examples/dalle_philip_seymour_in_cars_movie.jpg \
    circle_seymour.jpg
Logo

Layering

If we provide more than one expression separated by semicolons they will be alpha composited together. For example consider this DALLE generated bottle of ranch testifying in court;

Logo
# Superimpose a rotated version on the original;
iq -e "
    _ => p(_.y, _.x, _.r, _.g, _.b, _.a * 0.5);
    _ => p(_.x, _.y, _.r, _.g, _.b, _.a * 0.5);
" \
    assets/examples/dalle_ranch_testifying_in_court.jpg \
    rotate.jpg
Logo

Pixel Functions

There are a few builtin pixel functions like:

  • color_norm
  • color_add
  • color_scale
  • neighbors

That when combined with other standard features can even do some convolutions like this sobel edge detection:

# Crop into a circle and do sobel edge detection
iq -e "
  ([].w/2) >= sqrt(sq(_.x - center().x) + sq(_.y - center().y)) => color_norm(color_add(
      color_scale(neighbors(_, -1, -1), -1.0),
      color_scale(neighbors(_,  0, -1), -2.0),
      color_scale(neighbors(_,  1, -1), -1.0),
      color_scale(neighbors(_,  1, -1), 1.0),
      color_scale(neighbors(_,  1,  0), 2.0),
      color_scale(neighbors(_,  1,  1), 1.0)
  ));
" \
    assets/examples/dalle_ranch_testifying_in_court.jpg \
    circle_edge_ranch.jpg
Logo

Language Reference

Coming soon...

How it works

iq is written in rust and uses LALRPOP for parser/lexer generation.

Installation

Right now the tool is only distributed as source. Clone the repo and do a standard cargo build

Contributing

All contributions are welcome!

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

You might also like...
Automated builded images for rust-lang with rustup, "the ultimate way to install RUST"

rustup Automated builded images on store and hub for rust-lang with musl added, using rustup "the ultimate way to install RUST". tag changed: all3 -

Docker images for compiling static Rust binaries using musl-cross

rust-musl-cross Docker images for compiling static Rust binaries using musl-cross-make, inspired by rust-musl-builder Prebuilt images Currently we hav

A Rust library for calculating perceptual hash values of images

img_hash Now builds on stable Rust! (But needs nightly to bench.) A library for getting perceptual hash values of images. Thanks to Dr. Neal Krawetz f

Encoding and decoding images in Rust
Encoding and decoding images in Rust

Image Maintainers: @HeroicKatora, @fintelia How to contribute An Image Processing Library This crate provides basic image processing functions and met

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.
Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Speedy2D Hardware-accelerated drawing of shapes, images, and text, with an easy to use API. Speedy2D aims to be: The simplest Rust API for creating a

Zero dependency images (of chaos) in Rust
Zero dependency images (of chaos) in Rust

bifurcate-rs Zero dependency images (of chaos) in Rust To run: time cargo run --release img.pgm To convert from PGM to PNG using Image Magick: conve

tai (Terminal Ascii Image) tool to convert images to ascii written in Rust
tai (Terminal Ascii Image) tool to convert images to ascii written in Rust

TAI Terminal Ascii Image A tool to convert images to ascii art written in Rust 🦀 Notes This tool is still in development stage. Contributions All Con

Converts images into textual line art.
Converts images into textual line art.

img2utf Transform images to textual line art! Images require pre-processing to come out nice. It's expected that users will do the following: Apply ga

Manage lightweight VMs created from OCI images
Manage lightweight VMs created from OCI images

krunvm krunvm is a CLI-based utility for managing lightweight VMs created from OCI images, using libkrun and buildah. Features Minimal footprint Fast

Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

A small command-line application to view images from the terminal written in Rust.
A small command-line application to view images from the terminal written in Rust.

A small command-line application to view images from the terminal written in Rust. It is basically the front-end of viuer

Automated image compression for efficiently distributing images on the web.

Imager Apparently this project made it into the GitHub Archive Program. About Imager is a tool for automated image compression, and can competitively

Create evolving artistic images with hot-code-reloaded Lisp and GLSL.
Create evolving artistic images with hot-code-reloaded Lisp and GLSL.

Shadergarden is a tool for building hot-code-reloadable shader pipelines. For a tutorial for how to get started, consult the introductory

Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Fetch original quality URLs for images posted to a Twitter account

twitter-images Fetches the last tweets of a given account, then prints original quality URLs for all image tweets. Useful for archiving image content

Simple CLI program to generate zoomable tiled images
Simple CLI program to generate zoomable tiled images

zoomtiler Simple CLI program to generate deepzoom zoomable tiled images. The input can either be a single image or multiple images of the same height,

GUI based tool to sort and categorize images written in Rust
GUI based tool to sort and categorize images written in Rust

ImageSieve GUI based tool to sort out images based on similarity, categorize them according to their creation date and archive them in a target folder

TIF is a terminal_image_format. (theres no TIF editor, so i made TIF images through a hex editor lol)

Colors these are the colors you can use when displaying images on the terminal BYTES: 5A = BLUE 5B = BLACK 5C = RED 5D = GREEN 5E = PURPLE 5F = WHITE

A rust binary that will flip one or more bits of a file (mostly for messing with images for fun).
A rust binary that will flip one or more bits of a file (mostly for messing with images for fun).

file-bitflipper A rust binary that will flip one or more bits of a file (mostly for messing with images for fun). Example (bitflipped bentley) Usage $

Owner
Michael Giba
Michael Giba
Experimental Quantum Computer Simulator + Quantum Chess Implementation

Quantum Chess A somewhat hacky implementation of this paper (made in a week over a holiday). It's not heavily tested and probably has some bugs still

null 19 Jan 21, 2022
An experimental Rust crate for sigstore

Continuous integration Docs License This is an experimental crate to interact with sigstore. This is under high development, many features and checks

Flavio Castelli 0 Jan 10, 2022
Highly experimental, pure-Rust big integer library

grou-num (Pronounced "groo", from the Chiac meaning "big") This package is a highly experimental, unstable big integer library. I would not recommend

Patrick Poitras 1 Dec 18, 2021
An experimental, well-documented and expansion-ready virtual machine written in Rust.

Notice ivm is undergoing a complete refactor. ivm ivm is a rich, well-documented virtual machine written in Rust. Pros Documentation everywhere. Every

Imajin 4 Jul 9, 2022
Grebuloff is an experimental addon framework for Final Fantasy XIV.

Grebuloff Grebuloff is an experimental addon framework for Final Fantasy XIV. It introduces a new concept of what plugins can be, focusing on enabling

Ava Chaney 5 Jun 11, 2023
Experimental web UI library for Rust.

tachys This is an extremely experimental web UI library for Rust, exploring concepts of compile-time, trait-based, low-allocation patterns for UI temp

Greg Johnston 7 Aug 29, 2023
Rust library to generate word cloud images from text and images !

wordcloud-rs A Rust library to generate word-clouds from text and images! Example Code use std::collections::HashMap; use std::fs; use lazy_static::la

Teo Orthlieb 2 Dec 8, 2022
jq for images - experimental

iq - a little tool for image manipulation Inspired by `jq`, iq is an experimental tool for manipulating images through expressions which transform pix

Michael Giba 33 Nov 27, 2022
A web service that generates images of dependency graphs for crates hosted on crates.io

crate-deps A web service that generates images of dependency graphs for crates hosted on crates.io This project is built entirely in Rust using these

Corey Farwell 20 Nov 9, 2020
Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

rust-musl-builder: Docker container for easily building static Rust binaries Source on GitHub Changelog UPDATED: Major updates in this release which m

Eric Kidd 1.3k Jan 1, 2023