1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Joining images together into a single image.
//!
//! Provides two processes, each configured using the builder pattern:
//! - Selecting image files
//! - Copying the (typically resized) contents of those files into a single output image
//!
//! The first process is performed by the [`ImageFiles`] struct and its associated builder pattern.
//! Files are added either individually or from a directory.
//!
//! The second process is performed by the [`Stitch`] struct and its associated builder pattern.
//! The configuration sets the output image size and layout of the output image. The output image
//! is returned as an in-memory struct of type [`DynamicImage`], re-exported from the image crate
//! (see the [image crate on crates.io](https://crates.io/crates/image)).
//!
//! # Examples
//!
//! ```
//! // Select image files in current directory, take first 3 by alphabetic order on file name
//! use stitchy_core::{ImageFiles, OrderBy, TakeFrom};
//! let image_files = ImageFiles::builder()
//!     .add_current_directory(vec!["..", "..", "images", "demo"]).unwrap()
//!     .build().unwrap()
//!     .sort_and_truncate_by(3, OrderBy::Alphabetic, TakeFrom::Start, false).unwrap();
//!
//! // Stitch images in a horizontal line, restricting the width to 1000 pixels
//! use stitchy_core::{Stitch, AlignmentMode};
//! let stitch = Stitch::builder()
//!     .image_files(image_files).unwrap()
//!     .width_limit(1000)
//!     .alignment(AlignmentMode::Horizontal)
//!     .stitch();
//!
//! assert!(stitch.is_ok());
//! ```

mod enums;
mod files;
mod stitch;

#[cfg(test)]
mod tests;

/// Enums used for configuring the image stitching process
pub use enums::{OrderBy, TakeFrom};

/// Types used for loading files and passing them into the image stitching process
pub use files::{
    FileLocation,
    FileProperties,
    builder::ImageFilesBuilder,
    image::ImageFiles,
    path::{FilePath, FilePathWithMetadata},
    util::extension_formats
};

#[cfg(unix)]
pub use files::fd::{OwnedRawFdLocation, OwnedRawFdProperties};

/// Type used for running the image stitching process
pub use stitch::{Stitch, AlignmentMode, builder::StitchBuilder};

/// File utilities, used by the CLI crate
pub mod util {
    pub use crate::files::util::make_size_string;
}

/// Re-exports from the [image](https://crates.io/crates/image) crate
pub mod image {
    pub use image::{DynamicImage, GenericImage, ImageFormat, ImageOutputFormat, ImageError};
}