Skip to content

Avead556/image-chunker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-chunker

A CLI tool and Rust library for splitting large images into tiles with Excel-style naming (A1, A2, B1, B2, ...).

Features

  • Split images into fixed-size tiles
  • Excel-style tile naming (A1, A2, ... Z1, AA1, AB1, ...)
  • Support for PNG and JPEG output formats
  • Parallel processing with Rayon
  • Optional preview image generation
  • Configurable edge tile handling

Installation

From source

git clone https://github.com/yourusername/image-chunker
cd image-chunker
cargo install --path .

Using cargo

cargo install image-chunker

CLI Usage

image-chunker --input <IMAGE> --out <DIR> --tile-w <WIDTH> --tile-h <HEIGHT> [OPTIONS]

Options

Flag Description Default
-i, --input <PATH> Input image path Required
-o, --out <DIR> Output directory Required
--tile-w <PIXELS> Tile width in pixels Required
--tile-h <PIXELS> Tile height in pixels Required
--format <FORMAT> Output format: png or jpg png
--jpg-quality <1-100> JPEG quality (only for jpg) 85
--crop-edges Keep smaller edge tiles true
--preview Generate compressed preview false
--preview-quality <1-100> Preview JPEG quality 40

Examples

Split a large map into 256x256 PNG tiles:

image-chunker -i world_map.png -o ./tiles --tile-w 256 --tile-h 256

Create JPEG tiles with preview:

image-chunker -i photo.jpg -o ./output --tile-w 512 --tile-h 512 \
    --format jpg --jpg-quality 90 --preview

Library Usage

Add to your Cargo.toml:

[dependencies]
image-chunker = "0.1"

Example:

use image_chunker::{ChunkParams, OutputFormat, chunk_image};
use std::path::Path;

fn main() -> Result<(), image_chunker::ChunkerError> {
    let params = ChunkParams {
        input: Path::new("large_image.png").to_path_buf(),
        output_dir: Path::new("./tiles").to_path_buf(),
        tile_width: 256,
        tile_height: 256,
        format: OutputFormat::Png,
        jpeg_quality: 85,
        crop_edges: true,
    };

    let result = chunk_image(&params, |current, total| {
        println!("Progress: {}/{}", current, total);
    })?;

    println!("Created {} tiles ({} rows x {} cols)",
        result.tiles_created, result.rows, result.cols);

    Ok(())
}

Tile Naming Scheme

Tiles are named using Excel-style row letters and column numbers:

     Col 1   Col 2   Col 3   ...
Row A:  A1      A2      A3
Row B:  B1      B2      B3
...
Row Z:  Z1      Z2      Z3
Row AA: AA1     AA2     AA3
Row AB: AB1     AB2     AB3

For a 1000x1000 image with 256x256 tiles, you get:

  • 4 columns (1, 2, 3, 4)
  • 4 rows (A, B, C, D)
  • 16 tiles: A1.png, A2.png, ... D4.png

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages