0.0.5 • Published 5 days ago
splitea v0.0.5
splitea
It is a tool to split images into tiles or pieces. The idea is based on the project image-splitter.
It has just one entry point with three arguments and the response is an array of tiles:
image
: The image to split. It is a string path or a buffertiles
: All the information to create the tilesmode
: How to cut the imagesrows
/height
: Number of rows to be cut or height in px of each tilecolumns
/width
: Number of columns to be cut or width in px of each tileunique
: Options to specify if you just want tiles not repeateddistance
: Max distance between tiles to be filtereddifference
: Max difference between tiles to be filteredrequirement
: Condition to be filtered, one of them or both
output
: Information for the created tilesresponse
: Type of output, an array of Buffer (default) or the path of each tilestore
: Information if you want to store the tiles in the computer or notpath
: Where to storename
: Filename patternextension
: Extension of the tiles
For the tiles there are only these possible combinations:
mode
="horizontal"
+ (columns
|width
)mode
="vertical"
+ (rows
|height
)mode
="grid"
+ (columns
+rows
|width
+height
)
columns
and rows
are natural number while width
and height
are in pixels.
For the output the default type is buffer and it is not stored. If you want to store the tiles in the computer you'll have to add store object.
If you select response as "path"
you have to add store object too.
import { Splitea } from splitea
type Image = string | Buffer
type Tiles = {
mode: "horizontal" | "vertical" | "grid",
rows?: number,
columns?: number,
width?: number,
height?: number,
unique?: {
distance: number,
difference: number,
requirement: "one" | "both"
}
}
type Output = {
response: "buffer" | "path",
store?: {
path: string,
name: string,
extension?: "jpg" | "jpeg" | "png" | "bmp" | "gif" | "tiff"
}
}
const tiles: Promise<Image[]> = await Splitea(image: Image, tiles: Tiles, output: Output)