Skip to content

📷 Rust library, binary and wasm package to create photo mosaics

License

Notifications You must be signed in to change notification settings

loiccoyle/phomo-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy photo mosaics

Make your own photo mosaics here!

Prefer python? Check out loiccoyle/phomo!

This repo contains two crates:

  • phomo crate contains the photo mosaic generation library.
  • phomo-cli crate provides the command line interface to the phomo crate.

And one npm package:

  • phomo-wasm provides the wasm bindings and allows phomo to be used in the browser.

📦 Installation

Command line

Cargo

To use the phomo binary to build photo mosaics, install the phomo-cli crate:

cargo install phomo-cli

Arch linux (AUR)

Using your favourite AUR helper, install the phomo-git package:

paru -S phomo-git

Usage

Once installed, you can use the phomo binary.

Something like:

phomo master_image.png tile_directory/ output_mosaic.png

If doubt see the help:

$ phomo -h
Usage: phomo [OPTIONS] <MASTER_FILE> <TILE_DIR> <OUTPUT>

Arguments:
  <MASTER_FILE>  Master image
  <TILE_DIR>     Tile directory
  <OUTPUT>       Output mosaic file

Options:
  -g, --grid-size <WIDTH,HEIGHT>  Grid size, the number of tiles along the width and height
      --crop-tiles                Crop tiles to grid cell size
      --resize-tiles              Resize tiles to grid cell size
      --equalize                  Equalize the master and tile image color distributions
      --transfer-master-to-tiles  Transfer the color palette of the master image to the tile images
      --transfer-tiles-to-master  Transfer the color palette of the tile images to the master image
      --metric <METRIC>           The distance metric to use [default: norm-l1] [possible values: norm-l1, norm-l2]
  -v, --verbose...                Increase logging verbosity
  -q, --quiet...                  Decrease logging verbosity
  -h, --help                      Print help (see more with '--help')
  -V, --version                   Print version

Library

To use the library as a dependency in your projects, add the phomo crate:

cargo add phomo

See the docs for usage.

Wasm

To use the wasm bindings in your project, add the phomo-wasm npm package:

npm add phomo-wasm

I would recommend taking a look at the demo page's source code.