pixeli 0.1.8 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +341 -88
- package/dist/cli/commands/collage/index.d.ts +2 -0
- package/dist/cli/commands/collage/index.js +125 -0
- package/dist/cli/commands/grid/index.d.ts +2 -0
- package/dist/cli/commands/grid/index.js +127 -0
- package/dist/cli/commands/masonry/index.d.ts +2 -0
- package/dist/cli/commands/masonry/index.js +129 -0
- package/dist/cli/commands/template/index.d.ts +2 -0
- package/dist/cli/commands/template/index.js +123 -0
- package/dist/cli/commands/template/presets/artGallery.d.ts +15 -0
- package/dist/cli/commands/template/presets/artGallery.js +15 -0
- package/dist/cli/commands/template/presets/dashboardShot.d.ts +15 -0
- package/dist/cli/commands/template/presets/dashboardShot.js +16 -0
- package/dist/cli/commands/template/presets/horizontalBookSpread.d.ts +15 -0
- package/dist/cli/commands/template/presets/horizontalBookSpread.js +13 -0
- package/dist/cli/commands/template/presets/instagramGrid.d.ts +15 -0
- package/dist/cli/commands/template/presets/instagramGrid.js +16 -0
- package/dist/cli/commands/template/presets/verticalBookSpread.d.ts +15 -0
- package/dist/cli/commands/template/presets/verticalBookSpread.js +13 -0
- package/dist/cli/commands/template/presets.d.ts +73 -0
- package/{lib/merges/collage-merge → dist/cli/commands/template}/presets.js +6 -8
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +24 -0
- package/dist/cli/modules/loadImages.d.ts +15 -0
- package/dist/cli/modules/loadImages.js +74 -0
- package/dist/cli/modules/progressBar.d.ts +10 -0
- package/dist/cli/modules/progressBar.js +34 -0
- package/dist/cli/schemas/collage.d.ts +29 -0
- package/dist/cli/schemas/collage.js +38 -0
- package/dist/cli/schemas/grid.d.ts +34 -0
- package/dist/cli/schemas/grid.js +38 -0
- package/dist/cli/schemas/masonry.d.ts +62 -0
- package/dist/cli/schemas/masonry.js +62 -0
- package/dist/cli/schemas/template.d.ts +31 -0
- package/dist/cli/schemas/template.js +49 -0
- package/dist/cli/utils/buildCommandFromSchema.d.ts +8 -0
- package/dist/cli/utils/buildCommandFromSchema.js +55 -0
- package/dist/cli/utils/configureCommandErrors.d.ts +2 -0
- package/dist/cli/utils/configureCommandErrors.js +22 -0
- package/dist/cli/utils/stringFormatter.d.ts +1 -0
- package/dist/cli/utils/stringFormatter.js +3 -0
- package/dist/cli/utils/toErrorMessage.d.ts +4 -0
- package/dist/cli/utils/toErrorMessage.js +22 -0
- package/dist/core/helpers.d.ts +10 -0
- package/dist/core/helpers.js +42 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/mergeError.d.ts +9 -0
- package/dist/core/mergeError.js +10 -0
- package/dist/core/merges/collage/index.d.ts +9 -0
- package/dist/core/merges/collage/index.js +32 -0
- package/dist/core/merges/collage/steps/calculateImageDimensions.d.ts +12 -0
- package/dist/core/merges/collage/steps/calculateImageDimensions.js +18 -0
- package/dist/core/merges/collage/steps/createComposites.d.ts +8 -0
- package/dist/core/merges/collage/steps/createComposites.js +58 -0
- package/dist/core/merges/collage/steps/resizeAndBorderImages.d.ts +12 -0
- package/dist/core/merges/collage/steps/resizeAndBorderImages.js +26 -0
- package/dist/core/merges/collage/steps/rotateImages.d.ts +7 -0
- package/dist/core/merges/collage/steps/rotateImages.js +9 -0
- package/dist/core/merges/grid/index.d.ts +12 -0
- package/dist/core/merges/grid/index.js +36 -0
- package/dist/core/merges/grid/steps/calculateCanvasDimensions.d.ts +8 -0
- package/dist/core/merges/grid/steps/calculateCanvasDimensions.js +18 -0
- package/dist/core/merges/grid/steps/calculateFontSize.d.ts +7 -0
- package/dist/core/merges/grid/steps/calculateFontSize.js +19 -0
- package/dist/core/merges/grid/steps/calculateImageDimensions.d.ts +8 -0
- package/dist/core/merges/grid/steps/calculateImageDimensions.js +18 -0
- package/dist/core/merges/grid/steps/createComposites.d.ts +10 -0
- package/dist/core/merges/grid/steps/createComposites.js +63 -0
- package/dist/core/merges/grid/steps/prepareImages.d.ts +10 -0
- package/dist/core/merges/grid/steps/prepareImages.js +29 -0
- package/dist/core/merges/grid/steps/shuffleImagesAndCaptions.d.ts +7 -0
- package/dist/core/merges/grid/steps/shuffleImagesAndCaptions.js +17 -0
- package/dist/core/merges/index.d.ts +3 -0
- package/dist/core/merges/index.js +3 -0
- package/dist/core/merges/masonry/index.d.ts +10 -0
- package/dist/core/merges/masonry/index.js +32 -0
- package/dist/core/merges/masonry/steps/calculateCanvasDimensions.d.ts +15 -0
- package/dist/core/merges/masonry/steps/calculateCanvasDimensions.js +17 -0
- package/dist/core/merges/masonry/steps/calculateLaneSize.d.ts +9 -0
- package/dist/core/merges/masonry/steps/calculateLaneSize.js +27 -0
- package/dist/core/merges/masonry/steps/createComposites.d.ts +25 -0
- package/dist/core/merges/masonry/steps/createComposites.js +108 -0
- package/dist/core/merges/masonry/steps/resizeImages.d.ts +7 -0
- package/dist/core/merges/masonry/steps/resizeImages.js +14 -0
- package/dist/core/merges/masonry/steps/splitIntoLanes.d.ts +17 -0
- package/dist/core/merges/masonry/steps/splitIntoLanes.js +78 -0
- package/dist/core/merges/shared-steps/applyComposites.d.ts +2 -0
- package/dist/core/merges/shared-steps/applyComposites.js +16 -0
- package/dist/core/merges/shared-steps/createCanvas.d.ts +11 -0
- package/dist/core/merges/shared-steps/createCanvas.js +17 -0
- package/dist/core/merges/shared-steps/exportCanvas.d.ts +7 -0
- package/dist/core/merges/shared-steps/exportCanvas.js +25 -0
- package/dist/core/merges/shared-steps/finalizeImagePipelines.d.ts +2 -0
- package/dist/core/merges/shared-steps/finalizeImagePipelines.js +9 -0
- package/dist/core/merges/shared-steps/loadImages.d.ts +2 -0
- package/dist/core/merges/shared-steps/loadImages.js +26 -0
- package/dist/core/merges/shared-steps/validateCaptions.d.ts +10 -0
- package/dist/core/merges/shared-steps/validateCaptions.js +17 -0
- package/dist/core/merges/template/index.d.ts +10 -0
- package/dist/core/merges/template/index.js +28 -0
- package/dist/core/merges/template/steps/calculateSlotDimensions.d.ts +9 -0
- package/dist/core/merges/template/steps/calculateSlotDimensions.js +12 -0
- package/dist/core/merges/template/steps/createComposites.d.ts +10 -0
- package/dist/core/merges/template/steps/createComposites.js +25 -0
- package/dist/core/merges/template/steps/getBlocks.d.ts +13 -0
- package/dist/core/merges/template/steps/getBlocks.js +28 -0
- package/dist/core/merges/template/types.d.ts +21 -0
- package/dist/core/merges/template/types.js +1 -0
- package/dist/core/merges/types.d.ts +102 -0
- package/dist/core/merges/types.js +1 -0
- package/dist/core/modules/messages.d.ts +32 -0
- package/dist/core/modules/messages.js +54 -0
- package/dist/core/pipeline/guards.d.ts +4 -0
- package/dist/core/pipeline/guards.js +23 -0
- package/dist/core/pipeline/mergePipeline.d.ts +60 -0
- package/dist/core/pipeline/mergePipeline.js +122 -0
- package/dist/core/schemas/collage.d.ts +26 -0
- package/dist/core/schemas/collage.js +17 -0
- package/dist/core/schemas/grid.d.ts +32 -0
- package/dist/core/schemas/grid.js +29 -0
- package/dist/core/schemas/masonry.d.ts +56 -0
- package/dist/core/schemas/masonry.js +43 -0
- package/dist/core/schemas/template.d.ts +34 -0
- package/dist/core/schemas/template.js +88 -0
- package/dist/core/utils/colors/hexToRgba.d.ts +2 -0
- package/dist/core/utils/colors/hexToRgba.js +25 -0
- package/dist/core/utils/colors/rgbaToHex.d.ts +2 -0
- package/dist/core/utils/colors/rgbaToHex.js +15 -0
- package/dist/core/utils/colors/types.d.ts +7 -0
- package/dist/core/utils/colors/types.js +1 -0
- package/dist/core/utils/fonts/getFontSize.d.ts +9 -0
- package/dist/core/utils/fonts/getFontSize.js +40 -0
- package/dist/core/utils/images/addImageBorder.d.ts +13 -0
- package/dist/core/utils/images/addImageBorder.js +33 -0
- package/dist/core/utils/images/getImageHeights.d.ts +2 -0
- package/dist/core/utils/images/getImageHeights.js +9 -0
- package/dist/core/utils/images/getImageWidths.d.ts +2 -0
- package/dist/core/utils/images/getImageWidths.js +9 -0
- package/dist/core/utils/images/getSmallestImageDimensions.d.ts +5 -0
- package/dist/core/utils/images/getSmallestImageDimensions.js +9 -0
- package/dist/core/utils/images/handleImageEdges.d.ts +13 -0
- package/dist/core/utils/images/handleImageEdges.js +39 -0
- package/dist/core/utils/images/isActualImage.d.ts +5 -0
- package/dist/core/utils/images/isActualImage.js +26 -0
- package/dist/core/utils/images/parseAspectRatio.d.ts +1 -0
- package/dist/core/utils/images/parseAspectRatio.js +22 -0
- package/dist/core/utils/images/roundImage.d.ts +9 -0
- package/dist/core/utils/images/roundImage.js +27 -0
- package/dist/core/utils/images/roundImages.d.ts +8 -0
- package/dist/core/utils/images/roundImages.js +19 -0
- package/dist/core/utils/images/scaleImage.d.ts +8 -0
- package/dist/core/utils/images/scaleImage.js +36 -0
- package/dist/core/utils/images/scaleImages.d.ts +8 -0
- package/dist/core/utils/images/scaleImages.js +38 -0
- package/dist/core/utils/math/median.d.ts +1 -0
- package/dist/core/utils/math/median.js +12 -0
- package/dist/core/utils/math/randint.d.ts +6 -0
- package/dist/core/utils/math/randint.js +11 -0
- package/dist/core/utils/math/trimmedMedian.d.ts +1 -0
- package/dist/core/utils/math/trimmedMedian.js +12 -0
- package/dist/core/utils/svg/createSvgTextBuffer.d.ts +9 -0
- package/dist/core/utils/svg/createSvgTextBuffer.js +21 -0
- package/dist/validators/aspectRatio.d.ts +2 -0
- package/dist/validators/aspectRatio.js +15 -0
- package/dist/validators/coercion.d.ts +2 -0
- package/dist/validators/coercion.js +12 -0
- package/dist/validators/format.d.ts +2 -0
- package/dist/validators/format.js +15 -0
- package/dist/validators/hexColor.d.ts +7 -0
- package/dist/validators/hexColor.js +27 -0
- package/dist/validators/index.d.ts +95 -0
- package/dist/validators/index.js +64 -0
- package/dist/validators/outputFile.d.ts +2 -0
- package/dist/validators/outputFile.js +7 -0
- package/dist/validators/path.d.ts +3 -0
- package/dist/validators/path.js +18 -0
- package/dist/validators/sharpImageInput.d.ts +3 -0
- package/dist/validators/sharpImageInput.js +6 -0
- package/dist/validators/template.d.ts +15 -0
- package/dist/validators/template.js +41 -0
- package/package.json +26 -9
- package/bin/pixeli.js +0 -26
- package/commands/merge/collage.js +0 -83
- package/commands/merge/grid.js +0 -71
- package/commands/merge/helpers/utils.js +0 -11
- package/commands/merge/helpers/validations.js +0 -269
- package/commands/merge/index.js +0 -12
- package/commands/merge/masonry.js +0 -72
- package/lib/helpers/loadImages.js +0 -94
- package/lib/helpers/progressBar.js +0 -20
- package/lib/helpers/templateValidator.js +0 -139
- package/lib/helpers/utils.js +0 -208
- package/lib/merges/collage-merge/index.js +0 -110
- package/lib/merges/collage-merge/presets/artGallery.js +0 -17
- package/lib/merges/collage-merge/presets/dashboardShot.js +0 -18
- package/lib/merges/collage-merge/presets/horizontalBookSpread.js +0 -15
- package/lib/merges/collage-merge/presets/instagramGrid.js +0 -18
- package/lib/merges/collage-merge/presets/verticalBookSpread.js +0 -15
- package/lib/merges/grid-merge/index.js +0 -152
- package/lib/merges/masonry-merge/horizontal.js +0 -157
- package/lib/merges/masonry-merge/index.js +0 -57
- package/lib/merges/masonry-merge/vertical.js +0 -152
- package/lib/merges/merge-utils.js +0 -176
package/README.md
CHANGED
|
@@ -3,23 +3,60 @@
|
|
|
3
3
|
|
|
4
4
|
<img src="./assets/logo.svg" width="150" align="right">
|
|
5
5
|
|
|
6
|
-
**Pixeli** is a lightweight and flexible command-line tool for merging multiple images into clean, customizable grid layouts. It’s designed for speed and simplicity, making it ideal for generating collages, previews, gallery layouts, inspiration boards, and composite images without relying on heavy desktop software.
|
|
6
|
+
**Pixeli** is a typescript-first, lightweight, and flexible command-line tool and library for merging multiple images into clean, customizable grid layouts. It’s designed for speed and simplicity, making it ideal for generating collages, previews, gallery layouts, inspiration boards, and composite images without relying on heavy desktop software.
|
|
7
7
|
|
|
8
8
|
Pixeli uses Sharp, a Node.js wrapper for the libvips library which is based on C. This makes it an extremely fast tool with support for PNG, JPG, GIF, SVG, AVIF, etc.
|
|
9
9
|
|
|
10
|
-
The tool currently supports
|
|
10
|
+
The tool currently supports four main layout modes: ***Grid***, ***Masonry*** (horizontal / vertical), ***Template***, and ***Collage***. Each of them provide a distinct visual style to match a project's needs, for example:
|
|
11
11
|
|
|
12
12
|
| Grid (1:1 images) | Contact Sheet Grid |
|
|
13
13
|
|---|---|
|
|
14
14
|
| <img src="samples/grid.jpg" width="400"> | <img src="samples/grid-with-captions.jpg" width="400"> |
|
|
15
15
|
| **Masonry (Horizontal)** | **Masonry (Vertical)** |
|
|
16
16
|
| <img src="samples/masonry-horizontal.jpg" width="400"> | <img src="samples/masonry-vertical.jpg" width="400"> |
|
|
17
|
-
| **
|
|
17
|
+
| **Template (Instagram Grid)** | **Template (Vertical Book Spread)** |
|
|
18
18
|
| <img src="samples/instagram-grid.jpg" width="400"> | <img src="samples/vertical-book-spread.jpg" width="400"> |
|
|
19
|
-
| **
|
|
19
|
+
| **Template (Horizontal Book Spread)** | **Template (Dashboard Shot)** |
|
|
20
20
|
| <img src="samples/horizontal-book-spread.jpg" width="400"> | <img src="samples/dashboard-shot.jpg" width="400"> |
|
|
21
|
-
| **
|
|
22
|
-
| <img src="samples/art-gallery.jpg" width="400"> |
|
|
21
|
+
| **Template (Art Gallery)** | **Collage** |
|
|
22
|
+
| <img src="samples/art-gallery.jpg" width="400"> | <img src="samples/collage.jpg" width="400"> |
|
|
23
|
+
|
|
24
|
+
# Table of Contents
|
|
25
|
+
1. [Installation](#installation)
|
|
26
|
+
2. [Quick CLI Examples](#quick-cli-examples)
|
|
27
|
+
* [Basic Grid](#basic-grid)
|
|
28
|
+
* [Grid with Rectangular Images](#grid-with-rectangular-images)
|
|
29
|
+
* [Grid with 8 Columns](#grid-with-8-columns)
|
|
30
|
+
* [Contact Sheet](#contact-sheet)
|
|
31
|
+
* [Masonry Layout](#masonry-layout)
|
|
32
|
+
* [Template Layout](#template-layout)
|
|
33
|
+
* [Collage Layout](#collage-layout)
|
|
34
|
+
3. [Full CLI Documentation](#full-cli-documentation)
|
|
35
|
+
* [pixeli](#pixeli)
|
|
36
|
+
* [pixeli grid](#pixeli-grid)
|
|
37
|
+
* [pixeli masonry](#pixeli-masonry)
|
|
38
|
+
* [pixeli template](#pixeli-template)
|
|
39
|
+
* [pixeli collage](#pixeli-collage)
|
|
40
|
+
4. [Full Library Documentation](#full-library-documentation)
|
|
41
|
+
* [gridMerge Function Options](#gridmerge-function-options)
|
|
42
|
+
* [masonryMerge Function Options](#masonrymerge-function-options)
|
|
43
|
+
* [templateMerge Function Options](#templatemerge-function-options)
|
|
44
|
+
* [collageMerge Function Options](#collagemerge-function-options)
|
|
45
|
+
5. [Other](#other)
|
|
46
|
+
* [JSON Templates](#json-templates)
|
|
47
|
+
* [Canvas](#canvas)
|
|
48
|
+
* [Slots](#slots)
|
|
49
|
+
* [Slot Rules](#slot-rules)
|
|
50
|
+
* [Sample JSON Template](#sample-json-template)
|
|
51
|
+
* [All Supported Input Formats](#all-supported-input-formats)
|
|
52
|
+
* [All Supported Output Formats](#all-supported-output-formats)
|
|
53
|
+
* [Pixel Limits](#pixel-limits)
|
|
54
|
+
* [Colors and Transparency](#colors-and-transparency)
|
|
55
|
+
* [CLI](#cli)
|
|
56
|
+
* [Library](#library)
|
|
57
|
+
6. [License](#license)
|
|
58
|
+
|
|
59
|
+
|
|
23
60
|
|
|
24
61
|
## Installation
|
|
25
62
|
Pixeli can be installed using npm. Simply run the following command to install it globally on your machine:
|
|
@@ -27,20 +64,25 @@ Pixeli can be installed using npm. Simply run the following command to install i
|
|
|
27
64
|
npm i -g pixeli
|
|
28
65
|
```
|
|
29
66
|
|
|
67
|
+
If you're interested in the library functions and not the CLI, you can add it to your project instead of a global install:
|
|
68
|
+
```bash
|
|
69
|
+
npm i pixeli
|
|
70
|
+
```
|
|
71
|
+
|
|
30
72
|
You can also run pixeli directly with npx without installing it globally. This is convenient for quick experiments or one-off usage:
|
|
31
73
|
```bash
|
|
32
74
|
npx pixeli merge <subcommand> [options] <files...>
|
|
33
75
|
```
|
|
34
76
|
|
|
35
|
-
## Quick Examples
|
|
77
|
+
## Quick CLI Examples
|
|
36
78
|
To run these examples, you can visit the [GitHub Repository](https://github.com/pakdad-mousavi/pixeli) and use the images in the [Samples](https://github.com/pakdad-mousavi/pixeli/blob/main/samples/) directory, if you don't already have your own set of images.
|
|
37
79
|
|
|
38
|
-
All merge commands are under
|
|
80
|
+
All merge commands are under `pixeli` and can be used like so: `pixeli [merge-mode] [options]`
|
|
39
81
|
|
|
40
82
|
### Basic Grid
|
|
41
83
|
To create a basic grid with 1:1 images, you can use the grid merge command. You'll also need to provide the individual filepaths to use, or use the `-rd` (--recursive and --directory) flags to get all the images from the specified directory:
|
|
42
84
|
```bash
|
|
43
|
-
pixeli
|
|
85
|
+
pixeli grid -rd ./samples/images
|
|
44
86
|
```
|
|
45
87
|
|
|
46
88
|
Without the `-r` flag, only the images in the directory will be scanned, and any sub-directories will be ignored.
|
|
@@ -48,30 +90,30 @@ Without the `-r` flag, only the images in the directory will be scanned, and any
|
|
|
48
90
|
### Grid with Rectangular Images
|
|
49
91
|
To create a grid with images that all have the same aspect ratio, you can specify the aspect ratio to use for all images using the `--ar` flag:
|
|
50
92
|
```bash
|
|
51
|
-
pixeli
|
|
93
|
+
pixeli grid -rd ./samples/images --ar 16:9
|
|
52
94
|
```
|
|
53
95
|
|
|
54
96
|
### Grid with 8 Columns
|
|
55
97
|
You can also customize the number of columns that you'd like the final image to have using the `-c` flag, followed by the number of columns:
|
|
56
98
|
```bash
|
|
57
|
-
pixeli
|
|
99
|
+
pixeli grid -rd ./samples/images -c 8
|
|
58
100
|
```
|
|
59
101
|
|
|
60
102
|
### Contact Sheet
|
|
61
103
|
Contact sheet style grids can also be made using pixeli. To include each file name under its respective image, the `--ca` flag can be used:
|
|
62
104
|
```bash
|
|
63
|
-
pixeli
|
|
105
|
+
pixeli grid -rd ./samples/images --ca
|
|
64
106
|
```
|
|
65
107
|
|
|
66
108
|
The caption color can also be specified using the `--cc` flag, followed by a hex color:
|
|
67
109
|
```bash
|
|
68
|
-
pixeli
|
|
110
|
+
pixeli grid -rd ./samples/images --ca --cc "#ff0000"
|
|
69
111
|
```
|
|
70
112
|
|
|
71
113
|
### Masonry Layout
|
|
72
114
|
To create a masonry style image, you can use the masonry merge command. The `-rd` flag is used to specify which directory to use, and the canvas width can be specified using the `--cvw` flag:
|
|
73
115
|
```bash
|
|
74
|
-
pixeli
|
|
116
|
+
pixeli masonry -rd ./samples/images --cvw 4000
|
|
75
117
|
```
|
|
76
118
|
|
|
77
119
|
By default, the masonry merge command uses a horizontal flow, but a vertical one can be specified using the `-f` flag, followed by the `--cvh` to specify the canvas height:
|
|
@@ -79,31 +121,61 @@ By default, the masonry merge command uses a horizontal flow, but a vertical one
|
|
|
79
121
|
pixeli merge masonry -rd ./samples/images -f vertical --cvh 4000
|
|
80
122
|
```
|
|
81
123
|
|
|
124
|
+
Note that the masonry command always requires either the `--cvw` or `--cvh` option, depending on the flow.
|
|
125
|
+
|
|
126
|
+
### Template Layout
|
|
127
|
+
Template layouts require a JSON template which describe your specific layout. The `-t` flag is used to specify the path to a JSON template:
|
|
128
|
+
```bash
|
|
129
|
+
pixeli template -rd ./samples/images -t ./template.json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
You could also use one of the presets provided using the `-p` flag:
|
|
133
|
+
```bash
|
|
134
|
+
pixeli template -rd ./samples/images -p instagram-grid
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
To learn about the JSON template, see [JSON Templates](#json-templates).
|
|
138
|
+
|
|
82
139
|
### Collage Layout
|
|
83
|
-
Collage layouts
|
|
140
|
+
Collage layouts are similar to grid layouts, in a way. Images are arranged in a grid, jittered, rotated, and overlapped to create a photo-wall style grid:
|
|
141
|
+
```bash
|
|
142
|
+
pixeli collage -rd ./samples/images
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
To customize the image sizes, use the `-w` flag:
|
|
146
|
+
```bash
|
|
147
|
+
pixeli collage -rd ./samples/images -w 400
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
To change the overlap percentage of any two images in the collage, use the `--op` flag:
|
|
84
151
|
```bash
|
|
85
|
-
pixeli
|
|
152
|
+
pixeli collage -rd ./samples/images --op 10
|
|
86
153
|
```
|
|
87
154
|
|
|
88
|
-
|
|
155
|
+
For varying image sizes, you can use the `--wv` flag to change the image width variance (in pixels):
|
|
89
156
|
```bash
|
|
90
|
-
pixeli
|
|
157
|
+
pixeli collage -rd ./samples/images --wv 50
|
|
91
158
|
```
|
|
92
159
|
|
|
93
|
-
To
|
|
160
|
+
To change the minimum and maximum degrees to rotate each image by, use the `--rr` flag to customize the rotation range:
|
|
161
|
+
```bash
|
|
162
|
+
pixeli collage -rd ./samples/images --rr 15
|
|
163
|
+
```
|
|
94
164
|
|
|
95
|
-
## Full Documentation
|
|
165
|
+
## Full CLI Documentation
|
|
96
166
|
|
|
97
|
-
### pixeli
|
|
98
|
-
Usage: `pixeli
|
|
167
|
+
### pixeli
|
|
168
|
+
Usage: `pixeli <subcommand> [options] <input...> -o <output>`
|
|
99
169
|
|
|
100
|
-
The
|
|
170
|
+
The `pixeli` command is what allows you to create grids and mosaics with your images.
|
|
101
171
|
| Subcommand | Description | Options |
|
|
102
172
|
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
103
|
-
| `grid` | Merge images into a uniform
|
|
104
|
-
| `masonry` | Merge images into a **dynamic masonry layout**, preserving natural image proportions. Supports vertical or horizontal flow and alignment options. | See [masonry options table](#pixeli-
|
|
173
|
+
| `grid` | Merge images into a **uniform rows × columns grid**, optionally with captions and per-image aspect ratios. | See [grid options table](#pixeli-grid) |
|
|
174
|
+
| `masonry` | Merge images into a **dynamic masonry layout**, preserving natural image proportions. Supports vertical or horizontal flow and alignment options. | See [masonry options table](#pixeli-masonry) |
|
|
175
|
+
| `template` | Merge images into a **pre-defined layout**, based on the template provided, or the preset used. | See [template options table](#pixeli-template) |
|
|
176
|
+
| `collage` | Merge images into a **messy, photo-wall style grid**, great for posters or aesthetic layouts. | See [collage options table](#pixeli-collage) |
|
|
105
177
|
|
|
106
|
-
The following options and flags are shared for all of the subcommands under the `pixeli
|
|
178
|
+
The following options and flags are shared for all of the subcommands under the `pixeli` command:
|
|
107
179
|
| Option | Default | Description |
|
|
108
180
|
| ------------------------------ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
109
181
|
| `[files...]` | — | Image file paths to merge. You can specify multiple files or if you prefer directories, use `--dir`. |
|
|
@@ -113,13 +185,15 @@ The following options and flags are shared for all of the subcommands under the
|
|
|
113
185
|
| `-g`, `--gap <px>` | `50` | **Spacing (in pixels) between images** in the layout. Applies to both horizontal and vertical gaps. |
|
|
114
186
|
| `--cr`, `--corner-radius <px>` | `0` | How much to **round the corners** of each image in pixels. |
|
|
115
187
|
| `--bg`, `--canvas-color <hex>` | `#ffffff` | Sets the **background color of the canvas**. Accepts HEX values (e.g., `#000000` for black). |
|
|
188
|
+
| `--bw`, `--border-width <px>` | `0` | Sets the **width of the border** in pixels. |
|
|
189
|
+
| `--bc`, `--border-color <hex>` | `#000` | Sets the **color of the border, if any**. Accepts HEX values (e.g., `#000000` for black). |
|
|
116
190
|
| `-o`, `--output <file>` | `./pixeli.png` | Path for the **merged output image**. The format is inferred from the file extension (`.png`, `.jpg`, `.webp`, etc.). |
|
|
117
191
|
|
|
118
192
|
|
|
119
|
-
### pixeli
|
|
120
|
-
Usage: `pixeli
|
|
193
|
+
### pixeli grid
|
|
194
|
+
Usage: `pixeli grid [options] [files...]`
|
|
121
195
|
|
|
122
|
-
The grid
|
|
196
|
+
The grid merge arranges images into a clean, uniform grid with fixed columns and automatic row calculation. The table below displays all of the options available to this command:
|
|
123
197
|
| Option/Flag | Default | Description |
|
|
124
198
|
| ----------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
125
199
|
| `--ar`, `--aspect-ratio <width/height\|number>` | `1:1` | Sets the **per-image aspect ratio**. Accepts ratio expressions (`16/9`, `4:3`) or decimal values (`1.777`). Images are scaled as needed to match this ratio before placement. |
|
|
@@ -129,10 +203,10 @@ The grid mode arranges images into a clean, uniform grid with fixed columns and
|
|
|
129
203
|
| `--cc`, `--caption-color <hex>` | `#000000` | HEX color value for caption text (e.g., `#ffffff`, `#ff9900`). Affects all captions uniformly. |
|
|
130
204
|
| `--mcs`, `--max-caption-size <pt>` | `100` | Sets the **maximum allowed caption font size**. Useful when images are extremely large and the caption is not big enough. The renderer may auto-reduce the font size if necessary. |
|
|
131
205
|
|
|
132
|
-
### pixeli
|
|
133
|
-
Usage: `pixeli
|
|
206
|
+
### pixeli masonry
|
|
207
|
+
Usage: `pixeli masonry [options] [files...]`
|
|
134
208
|
|
|
135
|
-
The masonry
|
|
209
|
+
The masonry merge preserves each image’s natural shape, creating an organic brick-wall layout similar to Pinterest boards.
|
|
136
210
|
|
|
137
211
|
| Option/Flag | Default | Description |
|
|
138
212
|
| ---------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -144,70 +218,202 @@ The masonry mode preserves each image’s natural shape, creating an organic bri
|
|
|
144
218
|
| `--ha`, `--h-align <left\|center\|right\|justified>` | `justified` | Controls **horizontal alignment** of rows when in `horizontal` flow. `justified` overfills each row and crops the final image to fill up the canvas. |
|
|
145
219
|
| `--va`, `--v-align <top\|middle\|bottom\|justified>` | `justified` | Controls **vertical alignment** of columns when in `vertical` flow. `justified` overfills each column and crops the final image to fill up the canvas. |
|
|
146
220
|
|
|
147
|
-
### pixeli
|
|
148
|
-
Usage: `pixeli
|
|
221
|
+
### pixeli template
|
|
222
|
+
Usage: `pixeli template [options] [files...]`
|
|
223
|
+
|
|
224
|
+
The template merge requires a specified JSON template file, or JSON string. Images will be placed as per the template. If a preset ID is provided, both `--template` and `--mapping` are ignored.
|
|
225
|
+
|
|
226
|
+
| Option/Flag | Default | Description |
|
|
227
|
+
| ---------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
|
+
| `-t`, `--template <path>` | `null` | Sets the **path to the JSON template file** which will be used to arrange the collage. Either use `--template` or `--preset`. |
|
|
229
|
+
| `-p`, `--preset <preset-id>` | `null` | Use a **pre-defined collage preset** instead of providing your own. Available preset IDs: `instagram-grid`, `dashboardShot`, `horizontal-book-spread`, `vertical-book-spread`, `art-gallery` |
|
|
230
|
+
|
|
231
|
+
### pixeli collage
|
|
232
|
+
Usage: `pixeli collage [options] [files...]`
|
|
233
|
+
|
|
234
|
+
The collage merge arranges images into a messy, photo-wall style grid with fixed columns and automatic row calculation. The table below displays all of the options available to this command:
|
|
235
|
+
|
|
236
|
+
| Option/Flag | Default | Description |
|
|
237
|
+
| ----------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
238
|
+
| `--ar`, `--aspect-ratio <width/height\|number>` | `1:1` | Sets the **per-image aspect ratio**. Accepts ratio expressions (`16/9`, `4:3`) or decimal values (`1.777`). Images are scaled as needed to match this ratio before placement. |
|
|
239
|
+
| `-w`, `--image-width <px>` | *trimmed median image width* | Sets the **final width of each processed image** in the grid. The height is derived automatically based on the chosen aspect ratio. |
|
|
240
|
+
| `-c`, `--columns <n>` | `4` | Defines how many **images per row** are placed in the grid. The total number of rows is calculated from the number of inputs. |
|
|
241
|
+
| `--op`, `--overlap-percentage <percent>` | `25` | Defines the **percentage of both vertical and horizontal overlap** between any two images. A higher percentage results in tighter, more packed collages. |
|
|
242
|
+
| `--rr`, `--rotation-range <deg>` | `7` | Defines the **minimum and maximum rotation**. A random rotation of this amount in degrees will be applied to each image. For no rotation, a value of `0` can be used. |
|
|
243
|
+
| `--wv`, `--image-width-variance <px>` | `10` | Defines the **random variation in image width** that is added to each image width (image height variance is automatically calculated). This helps create more natural collages. A larger image variance results in more uneven image sizes. |
|
|
244
|
+
|
|
245
|
+
## Full Library Documentation
|
|
149
246
|
|
|
150
|
-
|
|
247
|
+
Pixeli also provides functions for every merge. They can be imported like so:
|
|
151
248
|
|
|
152
|
-
| Option/Flag | Default | Description |
|
|
153
|
-
| ---------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
154
|
-
| `-t`, `--template <path>` | `null` | Sets the **path to the JSON template file** which will be used to arrange the collage. Priority is given to this option if `--mapping` is not provided. |
|
|
155
|
-
| `-m`, `--mapping <string>` | `null` | Sets the **JSON string** which will be parsed to later arrange the collage. Priority is given to `--template` if both options are provided. |
|
|
156
|
-
| `-p`, `--preset <preset-id>` | `null` | Use a **predefined collage preset** instead of providing your own. Available preset IDs: `instagram-grid`, `dashboardShot`, `horizontal-book-spread`, `vertical-book-spread`, `art-gallery` |
|
|
157
249
|
|
|
158
|
-
### Collage Templates
|
|
159
|
-
The following javascript object thoroughly describes the shape of the JSON objects which are expected to be received. Logical checks are performed on the values after the template is validated. This is to ensure the collage can be created, for example, without any overlaps or 0 pixel-wide images:
|
|
160
250
|
```javascript
|
|
251
|
+
import { gridMerge, masonryMerge, templageMerge, collageMerge } from 'pixeli';
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
All merge functions have the following signature:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
interface MergeCommand<T> {
|
|
258
|
+
(
|
|
259
|
+
imageInputs: sharp.SharpInput[],
|
|
260
|
+
options: T,
|
|
261
|
+
onProgress?: (total: number, completed: number, phase: string): void;
|
|
262
|
+
): Promise<Buffer>;
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The `imageInputs` parameter takes an array of valid image inputs which will be processed by sharp to create sharp instances. An image input can be a `Buffer` object, any subclass of `Buffer`, a file path string, or any other input type supported by the Sharp `SharpInput` interface.
|
|
267
|
+
|
|
268
|
+
The `options` parameter is where merge-specific options are given as an object. Each merge function has their own set of supported options.
|
|
269
|
+
|
|
270
|
+
The `onProgress` parameter is optional. It is a callback function which is called everytime progress is made during a merge operation. If provided, it will receive a `ProgressInfo` object, which contains the total number of images to be processed, the number of completed images so far, and the current phase of the merge (e.g., "Merging images" or "Initializing").
|
|
271
|
+
|
|
272
|
+
⚠️ NOTE ⚠️: The `onProgress` callback will be changed in upcoming versions.
|
|
273
|
+
|
|
274
|
+
The returned value of the function, if successful, is a buffer containing the final mosaic. If not successful, a `MergeError` will be thrown. To learn more about error handling, see ***wopuhfewopifhvweproihvfewpoihv*** MergeErrors.
|
|
275
|
+
|
|
276
|
+
### gridMerge Function Options
|
|
277
|
+
|
|
278
|
+
The `gridMerge` function has the following set of options:
|
|
279
|
+
|
|
280
|
+
| Option | Data Type | Description |
|
|
281
|
+
| ---------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
282
|
+
| `shuffle` | `boolean` | Whether to randomize the image order before merging. |
|
|
283
|
+
| `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
|
|
284
|
+
| `gap` | `number` | Gap between images in pixels. |
|
|
285
|
+
| `canvasColor` | `Color` | Background color of the output canvas. |
|
|
286
|
+
| `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
|
|
287
|
+
| `borderColor` | `Color` | Color of the border around each image. |
|
|
288
|
+
| `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
|
|
289
|
+
| `aspectRatio` | `string \| number` | Aspect ratio of each image cell. Used to calculate image height based on the given width. Examples: `"16:9"`, `"3x2"`, or `1.777`. |
|
|
290
|
+
| `imageWidth` | `number \| undefined` | Width of each image cell in pixels. If undefined, the median width of the input images is used. |
|
|
291
|
+
| `columns` | `number` | Number of columns in the grid layout. |
|
|
292
|
+
| `caption` | `boolean` | Whether to render captions under images. |
|
|
293
|
+
| `captions` | `string[]` | Caption text for each image, in order. |
|
|
294
|
+
| `captionColor` | `Color` | Text color used for image captions. |
|
|
295
|
+
| `maxCaptionSize` | `number` | Maximum caption font size in pixels. |
|
|
296
|
+
|
|
297
|
+
### masonryMerge Function Options
|
|
298
|
+
|
|
299
|
+
The `masonryMerge` function has the following set of options:
|
|
300
|
+
|
|
301
|
+
| Option | Data Type | Description |
|
|
302
|
+
| -------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
303
|
+
| `shuffle` | `boolean` | Whether to randomize the image order before merging. |
|
|
304
|
+
| `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
|
|
305
|
+
| `gap` | `number` | Gap between images in pixels. |
|
|
306
|
+
| `canvasColor` | `Color` | Background color of the output canvas. |
|
|
307
|
+
| `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
|
|
308
|
+
| `borderColor` | `Color` | Color of the border around each image. |
|
|
309
|
+
| `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
|
|
310
|
+
| `rowHeight` | `number \| undefined` | Height of each row in pixels. Defaults to the trimmed median image height if undefined. Only applied in horizontal layouts. |
|
|
311
|
+
| `columnWidth` | `number \| undefined` | Width of each column in pixels. Defaults to the trimmed median image width if undefined. Only applied in vertical layouts. |
|
|
312
|
+
| `canvasWidth` | `number \| undefined` | Width of the entire output canvas in pixels. Required when using horizontal flow. |
|
|
313
|
+
| `canvasHeight` | `number \| undefined` | Height of the entire output canvas in pixels. Required when using vertical flow. |
|
|
314
|
+
| `flow` | `'horizontal' \| 'vertical'` | Orientation of the masonry layout. Determines whether items flow by rows (horizontal) or by columns (vertical). |
|
|
315
|
+
| `hAlign` | `'left' \| 'center' \| 'right' \| 'justified'` | Horizontal alignment of items within each row. Only applied in horizontal layouts. |
|
|
316
|
+
| `vAlign` | `'top' \| 'middle' \| 'bottom' \| 'justified'` | Vertical alignment of items within each column. Only applied in vertical layouts. |
|
|
317
|
+
|
|
318
|
+
### templateMerge Function Options
|
|
319
|
+
|
|
320
|
+
The `templateMerge` function has the following set of options:
|
|
321
|
+
|
|
322
|
+
| Option | Data Type | Description |
|
|
323
|
+
| -------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
324
|
+
| `shuffle` | `boolean` | Whether to randomize the image order before merging. |
|
|
325
|
+
| `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
|
|
326
|
+
| `gap` | `number` | Gap between images in pixels. |
|
|
327
|
+
| `canvasColor` | `Color` | Background color of the output canvas. |
|
|
328
|
+
| `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
|
|
329
|
+
| `borderColor` | `Color` | Color of the border around each image. |
|
|
330
|
+
| `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
|
|
331
|
+
| `template` | `Template` | An object definition describing the layout, slots, and canvas configuration used to place images. See [JSON Templates](#json-templates) for more information. |
|
|
332
|
+
|
|
333
|
+
### collageMerge Function Options
|
|
334
|
+
|
|
335
|
+
The `collageMerge` function has the following set of options:
|
|
336
|
+
|
|
337
|
+
| Option | Data Type | Description |
|
|
338
|
+
| -------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
339
|
+
| `shuffle` | `boolean` | Whether to randomize the image order before merging. |
|
|
340
|
+
| `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
|
|
341
|
+
| `canvasColor` | `Color` | Background color of the output canvas. |
|
|
342
|
+
| `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
|
|
343
|
+
| `borderColor` | `Color` | Color of the border around each image. |
|
|
344
|
+
| `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
|
|
345
|
+
| `imageWidth` | `number` | Width of each image cell in pixels. If undefined, the median input image width is used. |
|
|
346
|
+
| `aspectRatio` | `string \| number` | Aspect ratio used to calculate image height from width. Examples: `"16:9"`, `"3x2"`, or `1.777`. |
|
|
347
|
+
| `columns` | `number` | Number of columns in the collage grid. |
|
|
348
|
+
| `imageWidthVariance` | `number` | Maximum number of pixels that each image width may randomly vary from `imageWidth`, creating natural size variation. For example, `50` allows images to be up to ±50 pixels wider or narrower. |
|
|
349
|
+
| `overlapPercentage` | `number` | Estimated percentage of overlap between neighboring images. Higher values create a tighter, denser collage. |
|
|
350
|
+
| `rotationRange` | `number` | Maximum absolute rotation angle in degrees. A value of `10` produces a random rotation between `-10°` and `+10°`. |
|
|
351
|
+
|
|
352
|
+
## Other
|
|
353
|
+
|
|
354
|
+
### JSON Templates
|
|
355
|
+
JSON templates used with template merge accept a JSON object that defines a grid-based canvas layout and how content occupies it.
|
|
356
|
+
|
|
357
|
+
The layout consists of:
|
|
358
|
+
|
|
359
|
+
- A canvas definition (overall grid size)
|
|
360
|
+
- A list of slots describing how items are placed inside the grid
|
|
361
|
+
|
|
362
|
+
Logical checks are performed on the values after the template is validated. This is to ensure the mosaic can be created, for example, without any overlaps or 0 pixel-wide images.
|
|
363
|
+
|
|
364
|
+
#### canvas
|
|
365
|
+
|
|
366
|
+
The **canvas** object defines the size and structure of the grid:
|
|
367
|
+
```json
|
|
161
368
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
properties: {
|
|
169
|
-
width: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
170
|
-
height: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
171
|
-
columns: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
172
|
-
rows: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
173
|
-
gap: { type: 'number', minimum: 0, multipleOf: 1 },
|
|
174
|
-
background: { type: 'string' },
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
slots: {
|
|
179
|
-
type: 'array',
|
|
180
|
-
items: {
|
|
181
|
-
type: 'object',
|
|
182
|
-
required: ['col', 'row', 'colSpan', 'rowSpan'],
|
|
183
|
-
properties: {
|
|
184
|
-
col: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
185
|
-
row: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
186
|
-
colSpan: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
187
|
-
rowSpan: { type: 'number', minimum: 1, multipleOf: 1 },
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
369
|
+
"canvas": {
|
|
370
|
+
"width": 1200,
|
|
371
|
+
"height": 800,
|
|
372
|
+
"columns": 4,
|
|
373
|
+
"rows": 3
|
|
374
|
+
}
|
|
192
375
|
}
|
|
193
376
|
```
|
|
194
377
|
|
|
195
|
-
|
|
378
|
+
| Field | Type | Description |
|
|
379
|
+
| --------- | ------ | ---------------------------------------------------- |
|
|
380
|
+
| `width` | number | Canvas width in pixels. Must be a positive integer. |
|
|
381
|
+
| `height` | number | Canvas height in pixels. Must be a positive integer. |
|
|
382
|
+
| `columns` | number | Number of grid columns. Must be a positive integer. |
|
|
383
|
+
| `rows` | number | Number of grid rows. Must be a positive integer. |
|
|
196
384
|
|
|
197
|
-
|
|
385
|
+
#### slots
|
|
198
386
|
|
|
199
|
-
The
|
|
387
|
+
The **slots** array contains a series of slots, where each slot defines where an item should appear in the grid and how many grid cells it occupies:
|
|
200
388
|
|
|
201
|
-
For example:
|
|
202
389
|
```json
|
|
203
|
-
{
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
390
|
+
{
|
|
391
|
+
"slots": [
|
|
392
|
+
{ "col": 1, "row": 1, "colSpan": 2, "rowSpan": 1 },
|
|
393
|
+
{ "col": 3, "row": 2, "colSpan": 1, "rowSpan": 2 }
|
|
394
|
+
]
|
|
208
395
|
}
|
|
209
396
|
```
|
|
210
|
-
|
|
397
|
+
|
|
398
|
+
| Field | Type | Description |
|
|
399
|
+
| --------- | ------ | --------------------------------- |
|
|
400
|
+
| `col` | number | Starting column index (1-based). |
|
|
401
|
+
| `row` | number | Starting row index (1-based). |
|
|
402
|
+
| `colSpan` | number | Number of columns the slot spans. |
|
|
403
|
+
| `rowSpan` | number | Number of rows the slot spans. |
|
|
404
|
+
|
|
405
|
+
#### Slot Rules
|
|
406
|
+
|
|
407
|
+
- All values must be positive integers.
|
|
408
|
+
- Slots must fit within the grid:
|
|
409
|
+
```
|
|
410
|
+
col + colSpan - 1 ≤ columns
|
|
411
|
+
row + rowSpan - 1 ≤ rows
|
|
412
|
+
```
|
|
413
|
+
- Overlapping slots will be rejected.
|
|
414
|
+
- Slot indices start at 1, not 0.
|
|
415
|
+
|
|
416
|
+
#### Sample JSON Template
|
|
211
417
|
|
|
212
418
|
This is an example of a full JSON template:
|
|
213
419
|
```json
|
|
@@ -217,8 +423,6 @@ This is an example of a full JSON template:
|
|
|
217
423
|
"height": 1600,
|
|
218
424
|
"columns": 3,
|
|
219
425
|
"rows": 6,
|
|
220
|
-
"gap": 12,
|
|
221
|
-
"background": "#000"
|
|
222
426
|
},
|
|
223
427
|
"slots": [
|
|
224
428
|
{ "col": 1, "row": 1, "colSpan": 2, "rowSpan": 2 },
|
|
@@ -233,8 +437,57 @@ This is an example of a full JSON template:
|
|
|
233
437
|
|
|
234
438
|
Note that the `canvas.background` and `canvas.gap` properties are optional. If they are not provided, the defaults from the CLI options will be used. If both the CLI and template options exists, the template options take priority.
|
|
235
439
|
|
|
236
|
-
|
|
237
|
-
This project is licensed under the [MIT License](./LICENSE).
|
|
440
|
+
### All Supported Input Formats
|
|
238
441
|
|
|
239
|
-
|
|
240
|
-
|
|
442
|
+
- ***webp***
|
|
443
|
+
- ***gif***
|
|
444
|
+
- ***jpeg***
|
|
445
|
+
- ***jpg***
|
|
446
|
+
- ***png***
|
|
447
|
+
- ***tiff***
|
|
448
|
+
- ***avif***
|
|
449
|
+
- ***svg***
|
|
450
|
+
|
|
451
|
+
### All Supported Output Formats
|
|
452
|
+
|
|
453
|
+
- ***webp***
|
|
454
|
+
- ***gif***
|
|
455
|
+
- ***jpeg***
|
|
456
|
+
- ***jpg***
|
|
457
|
+
- ***png***
|
|
458
|
+
- ***tiff***
|
|
459
|
+
- ***avif***
|
|
460
|
+
|
|
461
|
+
### Pixel Limits
|
|
462
|
+
|
|
463
|
+
Generating extremely large images significantly reduces speed, and may also lead to pixel limit errors. All image formats have a maximum width and height, and if the created image exceeds those resolution limits, you will receive an error:
|
|
464
|
+
|
|
465
|
+
| Format | Typical Extension(s) | Max Width × Height | Notes |
|
|
466
|
+
| ---------------------------- | -------------------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
467
|
+
| **JPEG / JPG** | `.jpg`, `.jpeg` | **65,535 × 65,535 px** | Standard limit from JFIF/JPEG. No alpha. |
|
|
468
|
+
| **PNG** | `.png` | **~2,147,483,647 × 2,147,483,647 px** | Theoretical spec limit; real-world memory limits apply. Supports transparency. |
|
|
469
|
+
| **WebP** | `.webp` | **16,383 × 16,383 px** | Format standard limit — smaller than PNG/JPEG. |
|
|
470
|
+
| **GIF** | `.gif` | **65,536 × 65,536 px** | - |
|
|
471
|
+
| **BMP** | `.bmp` | **32,767×32,767 or ~2,147,483,647×2,147,483,647 px** | Depends on version/fields. |
|
|
472
|
+
| **TIFF** | `.tif`, `.tiff` | **4,294,967,295 × 4,294,967,295 px** (theoretical) | Very large; may be limited by software or memory. |
|
|
473
|
+
|
|
474
|
+
### Colors and Transparency
|
|
475
|
+
|
|
476
|
+
#### CLI
|
|
477
|
+
Hex colors are used in the CLI.
|
|
478
|
+
|
|
479
|
+
For fully transparent images, a value of `transparent` is allowed. Note that the transparency of the canvas itself is depends on the output format; `jpg`, for example, does not have an alpha channel.
|
|
480
|
+
|
|
481
|
+
Semi-transparency is also allowed, and can be achieved with hex colors of the format `#rrggbbaa`, where the last two hex values represent the transparency.
|
|
482
|
+
|
|
483
|
+
#### Library
|
|
484
|
+
Colors in the library functions are either objects or hex values. The `Color` type is used to describe colors:
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
type Color = { r: number; g: number; b: number; alpha: number } | string;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Given that a color object has been used instead of a hex value, note that `color.r`, `color.g`, and `color.b` are all values ranging from 0 to 255, while `color.alpha` is a value ranging from 0 to 1.
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
This project is licensed under the [MIT License](./LICENSE).
|