pixeli 0.1.9 → 1.0.4

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.
Files changed (212) hide show
  1. package/README.md +362 -88
  2. package/dist/cli/commands/collage/index.d.ts +2 -0
  3. package/dist/cli/commands/collage/index.js +125 -0
  4. package/dist/cli/commands/grid/index.d.ts +2 -0
  5. package/dist/cli/commands/grid/index.js +127 -0
  6. package/dist/cli/commands/masonry/index.d.ts +2 -0
  7. package/dist/cli/commands/masonry/index.js +129 -0
  8. package/dist/cli/commands/template/index.d.ts +2 -0
  9. package/dist/cli/commands/template/index.js +123 -0
  10. package/dist/cli/commands/template/presets/artGallery.d.ts +15 -0
  11. package/dist/cli/commands/template/presets/artGallery.js +15 -0
  12. package/dist/cli/commands/template/presets/dashboardShot.d.ts +15 -0
  13. package/dist/cli/commands/template/presets/dashboardShot.js +16 -0
  14. package/dist/cli/commands/template/presets/horizontalBookSpread.d.ts +15 -0
  15. package/dist/cli/commands/template/presets/horizontalBookSpread.js +13 -0
  16. package/dist/cli/commands/template/presets/instagramGrid.d.ts +15 -0
  17. package/dist/cli/commands/template/presets/instagramGrid.js +16 -0
  18. package/dist/cli/commands/template/presets/verticalBookSpread.d.ts +15 -0
  19. package/dist/cli/commands/template/presets/verticalBookSpread.js +13 -0
  20. package/dist/cli/commands/template/presets.d.ts +73 -0
  21. package/{lib/merges/collage-merge → dist/cli/commands/template}/presets.js +6 -8
  22. package/dist/cli/index.d.ts +2 -0
  23. package/dist/cli/index.js +24 -0
  24. package/dist/cli/modules/loadImages.d.ts +15 -0
  25. package/dist/cli/modules/loadImages.js +74 -0
  26. package/dist/cli/modules/progressBar.d.ts +10 -0
  27. package/dist/cli/modules/progressBar.js +34 -0
  28. package/dist/cli/schemas/collage.d.ts +29 -0
  29. package/dist/cli/schemas/collage.js +38 -0
  30. package/dist/cli/schemas/grid.d.ts +34 -0
  31. package/dist/cli/schemas/grid.js +38 -0
  32. package/dist/cli/schemas/masonry.d.ts +62 -0
  33. package/dist/cli/schemas/masonry.js +62 -0
  34. package/dist/cli/schemas/template.d.ts +31 -0
  35. package/dist/cli/schemas/template.js +49 -0
  36. package/dist/cli/utils/buildCommandFromSchema.d.ts +8 -0
  37. package/dist/cli/utils/buildCommandFromSchema.js +55 -0
  38. package/dist/cli/utils/configureCommandErrors.d.ts +2 -0
  39. package/dist/cli/utils/configureCommandErrors.js +22 -0
  40. package/dist/cli/utils/stringFormatter.d.ts +1 -0
  41. package/dist/cli/utils/stringFormatter.js +3 -0
  42. package/dist/cli/utils/toErrorMessage.d.ts +4 -0
  43. package/dist/cli/utils/toErrorMessage.js +22 -0
  44. package/dist/core/helpers.d.ts +10 -0
  45. package/dist/core/helpers.js +42 -0
  46. package/dist/core/index.d.ts +2 -0
  47. package/dist/core/index.js +2 -0
  48. package/dist/core/jobs/batchRunner.d.ts +44 -0
  49. package/dist/core/jobs/batchRunner.js +90 -0
  50. package/dist/core/jobs/types.d.ts +10 -0
  51. package/dist/core/jobs/types.js +1 -0
  52. package/dist/core/mergeError.d.ts +9 -0
  53. package/dist/core/mergeError.js +10 -0
  54. package/dist/core/merges/collage/index.d.ts +9 -0
  55. package/dist/core/merges/collage/index.js +32 -0
  56. package/dist/core/merges/collage/steps/calculateImageDimensions.d.ts +12 -0
  57. package/dist/core/merges/collage/steps/calculateImageDimensions.js +18 -0
  58. package/dist/core/merges/collage/steps/createComposites.d.ts +8 -0
  59. package/dist/core/merges/collage/steps/createComposites.js +58 -0
  60. package/dist/core/merges/collage/steps/resizeAndBorderImages.d.ts +12 -0
  61. package/dist/core/merges/collage/steps/resizeAndBorderImages.js +26 -0
  62. package/dist/core/merges/collage/steps/rotateImages.d.ts +7 -0
  63. package/dist/core/merges/collage/steps/rotateImages.js +9 -0
  64. package/dist/core/merges/grid/index.d.ts +12 -0
  65. package/dist/core/merges/grid/index.js +36 -0
  66. package/dist/core/merges/grid/steps/calculateCanvasDimensions.d.ts +8 -0
  67. package/dist/core/merges/grid/steps/calculateCanvasDimensions.js +18 -0
  68. package/dist/core/merges/grid/steps/calculateFontSize.d.ts +7 -0
  69. package/dist/core/merges/grid/steps/calculateFontSize.js +19 -0
  70. package/dist/core/merges/grid/steps/calculateImageDimensions.d.ts +8 -0
  71. package/dist/core/merges/grid/steps/calculateImageDimensions.js +18 -0
  72. package/dist/core/merges/grid/steps/createComposites.d.ts +10 -0
  73. package/dist/core/merges/grid/steps/createComposites.js +63 -0
  74. package/dist/core/merges/grid/steps/prepareImages.d.ts +10 -0
  75. package/dist/core/merges/grid/steps/prepareImages.js +29 -0
  76. package/dist/core/merges/grid/steps/shuffleImagesAndCaptions.d.ts +7 -0
  77. package/dist/core/merges/grid/steps/shuffleImagesAndCaptions.js +17 -0
  78. package/dist/core/merges/index.d.ts +5 -0
  79. package/dist/core/merges/index.js +4 -0
  80. package/dist/core/merges/masonry/index.d.ts +10 -0
  81. package/dist/core/merges/masonry/index.js +32 -0
  82. package/dist/core/merges/masonry/steps/calculateCanvasDimensions.d.ts +15 -0
  83. package/dist/core/merges/masonry/steps/calculateCanvasDimensions.js +17 -0
  84. package/dist/core/merges/masonry/steps/calculateLaneSize.d.ts +9 -0
  85. package/dist/core/merges/masonry/steps/calculateLaneSize.js +27 -0
  86. package/dist/core/merges/masonry/steps/createComposites.d.ts +25 -0
  87. package/dist/core/merges/masonry/steps/createComposites.js +108 -0
  88. package/dist/core/merges/masonry/steps/resizeImages.d.ts +7 -0
  89. package/dist/core/merges/masonry/steps/resizeImages.js +14 -0
  90. package/dist/core/merges/masonry/steps/splitIntoLanes.d.ts +17 -0
  91. package/dist/core/merges/masonry/steps/splitIntoLanes.js +78 -0
  92. package/dist/core/merges/shared-steps/applyComposites.d.ts +2 -0
  93. package/dist/core/merges/shared-steps/applyComposites.js +16 -0
  94. package/dist/core/merges/shared-steps/createCanvas.d.ts +11 -0
  95. package/dist/core/merges/shared-steps/createCanvas.js +17 -0
  96. package/dist/core/merges/shared-steps/exportCanvas.d.ts +7 -0
  97. package/dist/core/merges/shared-steps/exportCanvas.js +25 -0
  98. package/dist/core/merges/shared-steps/finalizeImagePipelines.d.ts +2 -0
  99. package/dist/core/merges/shared-steps/finalizeImagePipelines.js +9 -0
  100. package/dist/core/merges/shared-steps/loadImages.d.ts +2 -0
  101. package/dist/core/merges/shared-steps/loadImages.js +26 -0
  102. package/dist/core/merges/shared-steps/validateCaptions.d.ts +10 -0
  103. package/dist/core/merges/shared-steps/validateCaptions.js +17 -0
  104. package/dist/core/merges/template/index.d.ts +10 -0
  105. package/dist/core/merges/template/index.js +28 -0
  106. package/dist/core/merges/template/steps/calculateSlotDimensions.d.ts +9 -0
  107. package/dist/core/merges/template/steps/calculateSlotDimensions.js +12 -0
  108. package/dist/core/merges/template/steps/createComposites.d.ts +10 -0
  109. package/dist/core/merges/template/steps/createComposites.js +25 -0
  110. package/dist/core/merges/template/steps/getBlocks.d.ts +13 -0
  111. package/dist/core/merges/template/steps/getBlocks.js +28 -0
  112. package/dist/core/merges/template/types.d.ts +21 -0
  113. package/dist/core/merges/template/types.js +1 -0
  114. package/dist/core/merges/types.d.ts +123 -0
  115. package/dist/core/merges/types.js +1 -0
  116. package/dist/core/modules/messages.d.ts +32 -0
  117. package/dist/core/modules/messages.js +54 -0
  118. package/dist/core/modules/typedEventEmitter.d.ts +7 -0
  119. package/dist/core/modules/typedEventEmitter.js +9 -0
  120. package/dist/core/pipeline/guards.d.ts +4 -0
  121. package/dist/core/pipeline/guards.js +23 -0
  122. package/dist/core/pipeline/mergePipeline.d.ts +60 -0
  123. package/dist/core/pipeline/mergePipeline.js +122 -0
  124. package/dist/core/schemas/collage.d.ts +26 -0
  125. package/dist/core/schemas/collage.js +17 -0
  126. package/dist/core/schemas/grid.d.ts +32 -0
  127. package/dist/core/schemas/grid.js +29 -0
  128. package/dist/core/schemas/masonry.d.ts +56 -0
  129. package/dist/core/schemas/masonry.js +43 -0
  130. package/dist/core/schemas/mergeJob.d.ts +11 -0
  131. package/dist/core/schemas/mergeJob.js +6 -0
  132. package/dist/core/schemas/template.d.ts +34 -0
  133. package/dist/core/schemas/template.js +88 -0
  134. package/dist/core/utils/colors/hexToRgba.d.ts +2 -0
  135. package/dist/core/utils/colors/hexToRgba.js +25 -0
  136. package/dist/core/utils/colors/rgbaToHex.d.ts +2 -0
  137. package/dist/core/utils/colors/rgbaToHex.js +15 -0
  138. package/dist/core/utils/colors/types.d.ts +7 -0
  139. package/dist/core/utils/colors/types.js +1 -0
  140. package/dist/core/utils/fonts/getFontSize.d.ts +9 -0
  141. package/dist/core/utils/fonts/getFontSize.js +40 -0
  142. package/dist/core/utils/images/addImageBorder.d.ts +13 -0
  143. package/dist/core/utils/images/addImageBorder.js +33 -0
  144. package/dist/core/utils/images/getImageHeights.d.ts +2 -0
  145. package/dist/core/utils/images/getImageHeights.js +9 -0
  146. package/dist/core/utils/images/getImageWidths.d.ts +2 -0
  147. package/dist/core/utils/images/getImageWidths.js +9 -0
  148. package/dist/core/utils/images/getSmallestImageDimensions.d.ts +5 -0
  149. package/dist/core/utils/images/getSmallestImageDimensions.js +9 -0
  150. package/dist/core/utils/images/handleImageEdges.d.ts +13 -0
  151. package/dist/core/utils/images/handleImageEdges.js +39 -0
  152. package/dist/core/utils/images/isActualImage.d.ts +5 -0
  153. package/dist/core/utils/images/isActualImage.js +26 -0
  154. package/dist/core/utils/images/parseAspectRatio.d.ts +1 -0
  155. package/dist/core/utils/images/parseAspectRatio.js +22 -0
  156. package/dist/core/utils/images/roundImage.d.ts +9 -0
  157. package/dist/core/utils/images/roundImage.js +27 -0
  158. package/dist/core/utils/images/roundImages.d.ts +8 -0
  159. package/dist/core/utils/images/roundImages.js +19 -0
  160. package/dist/core/utils/images/scaleImage.d.ts +8 -0
  161. package/dist/core/utils/images/scaleImage.js +36 -0
  162. package/dist/core/utils/images/scaleImages.d.ts +8 -0
  163. package/dist/core/utils/images/scaleImages.js +38 -0
  164. package/dist/core/utils/math/median.d.ts +1 -0
  165. package/dist/core/utils/math/median.js +12 -0
  166. package/dist/core/utils/math/randint.d.ts +6 -0
  167. package/dist/core/utils/math/randint.js +11 -0
  168. package/dist/core/utils/math/trimmedMedian.d.ts +1 -0
  169. package/dist/core/utils/math/trimmedMedian.js +12 -0
  170. package/dist/core/utils/svg/createSvgTextBuffer.d.ts +9 -0
  171. package/dist/core/utils/svg/createSvgTextBuffer.js +21 -0
  172. package/dist/validators/aspectRatio.d.ts +2 -0
  173. package/dist/validators/aspectRatio.js +15 -0
  174. package/dist/validators/coercion.d.ts +2 -0
  175. package/dist/validators/coercion.js +12 -0
  176. package/dist/validators/format.d.ts +2 -0
  177. package/dist/validators/format.js +15 -0
  178. package/dist/validators/hexColor.d.ts +7 -0
  179. package/dist/validators/hexColor.js +27 -0
  180. package/dist/validators/index.d.ts +95 -0
  181. package/dist/validators/index.js +64 -0
  182. package/dist/validators/outputFile.d.ts +2 -0
  183. package/dist/validators/outputFile.js +7 -0
  184. package/dist/validators/path.d.ts +3 -0
  185. package/dist/validators/path.js +18 -0
  186. package/dist/validators/sharpImageInput.d.ts +3 -0
  187. package/dist/validators/sharpImageInput.js +6 -0
  188. package/dist/validators/template.d.ts +15 -0
  189. package/dist/validators/template.js +41 -0
  190. package/package.json +26 -9
  191. package/bin/pixeli.js +0 -26
  192. package/commands/merge/collage.js +0 -83
  193. package/commands/merge/grid.js +0 -71
  194. package/commands/merge/helpers/utils.js +0 -11
  195. package/commands/merge/helpers/validations.js +0 -269
  196. package/commands/merge/index.js +0 -12
  197. package/commands/merge/masonry.js +0 -72
  198. package/lib/helpers/loadImages.js +0 -94
  199. package/lib/helpers/progressBar.js +0 -20
  200. package/lib/helpers/templateValidator.js +0 -139
  201. package/lib/helpers/utils.js +0 -208
  202. package/lib/merges/collage-merge/index.js +0 -110
  203. package/lib/merges/collage-merge/presets/artGallery.js +0 -17
  204. package/lib/merges/collage-merge/presets/dashboardShot.js +0 -18
  205. package/lib/merges/collage-merge/presets/horizontalBookSpread.js +0 -15
  206. package/lib/merges/collage-merge/presets/instagramGrid.js +0 -18
  207. package/lib/merges/collage-merge/presets/verticalBookSpread.js +0 -15
  208. package/lib/merges/grid-merge/index.js +0 -152
  209. package/lib/merges/masonry-merge/horizontal.js +0 -157
  210. package/lib/merges/masonry-merge/index.js +0 -57
  211. package/lib/merges/masonry-merge/vertical.js +0 -152
  212. package/lib/merges/merge-utils.js +0 -176
package/README.md CHANGED
@@ -3,23 +3,61 @@
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 two main layout modes: ***Grid*** and ***Masonry*** (horizontal / vertical). Each of them provide a distinct visual style to match a project's needs, for example:
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
- | **Collage (Instagram Grid)** | **Collage (Vertical Book Spread)** |
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
- | **Collage (Horizontal Book Spread)** | **Collage (Dashboard Shot)** |
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
- | **Collage (Art Gallery)** |
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
+ * [Error Handling](#error-handling)
55
+ * [Colors and Transparency](#colors-and-transparency)
56
+ * [CLI](#cli)
57
+ * [Library](#library)
58
+ 6. [License](#license)
59
+
60
+
23
61
 
24
62
  ## Installation
25
63
  Pixeli can be installed using npm. Simply run the following command to install it globally on your machine:
@@ -27,20 +65,25 @@ Pixeli can be installed using npm. Simply run the following command to install i
27
65
  npm i -g pixeli
28
66
  ```
29
67
 
68
+ If you're interested in the library functions and not the CLI, you can add it to your project instead of a global install:
69
+ ```bash
70
+ npm i pixeli
71
+ ```
72
+
30
73
  You can also run pixeli directly with npx without installing it globally. This is convenient for quick experiments or one-off usage:
31
74
  ```bash
32
75
  npx pixeli merge <subcommand> [options] <files...>
33
76
  ```
34
77
 
35
- ## Quick Examples
78
+ ## Quick CLI Examples
36
79
  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
80
 
38
- All merge commands are under the `pixeli merge` command and can be used like so: `pixeli merge [merge-mode] [options]`
81
+ All merge commands are under `pixeli` and can be used like so: `pixeli [merge-mode] [options]`
39
82
 
40
83
  ### Basic Grid
41
84
  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
85
  ```bash
43
- pixeli merge grid -rd ./samples/images
86
+ pixeli grid -rd ./samples/images
44
87
  ```
45
88
 
46
89
  Without the `-r` flag, only the images in the directory will be scanned, and any sub-directories will be ignored.
@@ -48,30 +91,30 @@ Without the `-r` flag, only the images in the directory will be scanned, and any
48
91
  ### Grid with Rectangular Images
49
92
  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
93
  ```bash
51
- pixeli merge grid -rd ./samples/images --ar 16:9
94
+ pixeli grid -rd ./samples/images --ar 16:9
52
95
  ```
53
96
 
54
97
  ### Grid with 8 Columns
55
98
  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
99
  ```bash
57
- pixeli merge grid -rd ./samples/images -c 8
100
+ pixeli grid -rd ./samples/images -c 8
58
101
  ```
59
102
 
60
103
  ### Contact Sheet
61
104
  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
105
  ```bash
63
- pixeli merge grid -rd ./samples/images --ca
106
+ pixeli grid -rd ./samples/images --ca
64
107
  ```
65
108
 
66
109
  The caption color can also be specified using the `--cc` flag, followed by a hex color:
67
110
  ```bash
68
- pixeli merge grid -rd ./samples/images --ca --cc "#ff0000"
111
+ pixeli grid -rd ./samples/images --ca --cc "#ff0000"
69
112
  ```
70
113
 
71
114
  ### Masonry Layout
72
115
  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
116
  ```bash
74
- pixeli merge masonry -rd ./samples/images --cvw 4000
117
+ pixeli masonry -rd ./samples/images --cvw 4000
75
118
  ```
76
119
 
77
120
  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 +122,61 @@ By default, the masonry merge command uses a horizontal flow, but a vertical one
79
122
  pixeli merge masonry -rd ./samples/images -f vertical --cvh 4000
80
123
  ```
81
124
 
125
+ Note that the masonry command always requires either the `--cvw` or `--cvh` option, depending on the flow.
126
+
127
+ ### Template Layout
128
+ Template layouts require a JSON template which describe your specific layout. The `-t` flag is used to specify the path to a JSON template:
129
+ ```bash
130
+ pixeli template -rd ./samples/images -t ./template.json
131
+ ```
132
+
133
+ You could also use one of the presets provided using the `-p` flag:
134
+ ```bash
135
+ pixeli template -rd ./samples/images -p instagram-grid
136
+ ```
137
+
138
+ To learn about the JSON template, see [JSON Templates](#json-templates).
139
+
82
140
  ### Collage Layout
83
- Collage layouts require a JSON template, or an inline JSON string, which describe your specific layout. The `-t` flag is used to specify the path to a JSON template, whereas the `-m` flag is used to provide inline JSON:
141
+ 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:
84
142
  ```bash
85
- pixeli merge collage -rd ./samples/images -t ./template.json
143
+ pixeli collage -rd ./samples/images
86
144
  ```
87
145
 
88
- You could also use a preset, and also round all the image corners in your collage:
146
+ To customize the image sizes, use the `-w` flag:
89
147
  ```bash
90
- pixeli merge collage -rd ./samples/images -t ./template.json --cr 100
148
+ pixeli collage -rd ./samples/images -w 400
91
149
  ```
92
150
 
93
- To learn about the JSON template, see [collage templates](#collage-templates).
151
+ To change the overlap percentage of any two images in the collage, use the `--op` flag:
152
+ ```bash
153
+ pixeli collage -rd ./samples/images --op 10
154
+ ```
94
155
 
95
- ## Full Documentation
156
+ For varying image sizes, you can use the `--wv` flag to change the image width variance (in pixels):
157
+ ```bash
158
+ pixeli collage -rd ./samples/images --wv 50
159
+ ```
96
160
 
97
- ### pixeli merge
98
- Usage: `pixeli merge <subcommand> [options] <input...> -o <output>`
161
+ To change the minimum and maximum degrees to rotate each image by, use the `--rr` flag to customize the rotation range:
162
+ ```bash
163
+ pixeli collage -rd ./samples/images --rr 15
164
+ ```
165
+
166
+ ## Full CLI Documentation
167
+
168
+ ### pixeli
169
+ Usage: `pixeli <subcommand> [options] <input...> -o <output>`
99
170
 
100
- The merge command is what allows you to create grids and mosaics with your images.
171
+ The `pixeli` command is what allows you to create grids and mosaics with your images.
101
172
  | Subcommand | Description | Options |
102
173
  | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
103
- | `grid` | Merge images into a uniform **rows × columns grid**, optionally with captions and per-image aspect ratios. | See [grid options table](#pixeli-merge-grid) |
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-merge-masonry) |
174
+ | `grid` | Merge images into a **uniform rows × columns grid**, optionally with captions and per-image aspect ratios. | See [grid options table](#pixeli-grid) |
175
+ | `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) |
176
+ | `template` | Merge images into a **pre-defined layout**, based on the template provided, or the preset used. | See [template options table](#pixeli-template) |
177
+ | `collage` | Merge images into a **messy, photo-wall style grid**, great for posters or aesthetic layouts. | See [collage options table](#pixeli-collage) |
105
178
 
106
- The following options and flags are shared for all of the subcommands under the `pixeli merge` command:
179
+ The following options and flags are shared for all of the subcommands under the `pixeli` command:
107
180
  | Option | Default | Description |
108
181
  | ------------------------------ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
109
182
  | `[files...]` | — | Image file paths to merge. You can specify multiple files or if you prefer directories, use `--dir`. |
@@ -113,13 +186,15 @@ The following options and flags are shared for all of the subcommands under the
113
186
  | `-g`, `--gap <px>` | `50` | **Spacing (in pixels) between images** in the layout. Applies to both horizontal and vertical gaps. |
114
187
  | `--cr`, `--corner-radius <px>` | `0` | How much to **round the corners** of each image in pixels. |
115
188
  | `--bg`, `--canvas-color <hex>` | `#ffffff` | Sets the **background color of the canvas**. Accepts HEX values (e.g., `#000000` for black). |
189
+ | `--bw`, `--border-width <px>` | `0` | Sets the **width of the border** in pixels. |
190
+ | `--bc`, `--border-color <hex>` | `#000` | Sets the **color of the border, if any**. Accepts HEX values (e.g., `#000000` for black). |
116
191
  | `-o`, `--output <file>` | `./pixeli.png` | Path for the **merged output image**. The format is inferred from the file extension (`.png`, `.jpg`, `.webp`, etc.). |
117
192
 
118
193
 
119
- ### pixeli merge grid
120
- Usage: `pixeli merge grid [options] [files...]`
194
+ ### pixeli grid
195
+ Usage: `pixeli grid [options] [files...]`
121
196
 
122
- The grid mode 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:
197
+ 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
198
  | Option/Flag | Default | Description |
124
199
  | ----------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
125
200
  | `--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 +204,10 @@ The grid mode arranges images into a clean, uniform grid with fixed columns and
129
204
  | `--cc`, `--caption-color <hex>` | `#000000` | HEX color value for caption text (e.g., `#ffffff`, `#ff9900`). Affects all captions uniformly. |
130
205
  | `--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
206
 
132
- ### pixeli merge masonry
133
- Usage: `pixeli merge masonry [options] [files...]`
207
+ ### pixeli masonry
208
+ Usage: `pixeli masonry [options] [files...]`
134
209
 
135
- The masonry mode preserves each image’s natural shape, creating an organic brick-wall layout similar to Pinterest boards.
210
+ The masonry merge preserves each image’s natural shape, creating an organic brick-wall layout similar to Pinterest boards.
136
211
 
137
212
  | Option/Flag | Default | Description |
138
213
  | ---------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -144,70 +219,202 @@ The masonry mode preserves each image’s natural shape, creating an organic bri
144
219
  | `--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
220
  | `--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
221
 
147
- ### pixeli merge collage
148
- Usage: `pixeli merge collage [options] [files...]`
222
+ ### pixeli template
223
+ Usage: `pixeli template [options] [files...]`
224
+
225
+ 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.
226
+
227
+ | Option/Flag | Default | Description |
228
+ | ---------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
229
+ | `-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`. |
230
+ | `-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` |
231
+
232
+ ### pixeli collage
233
+ Usage: `pixeli collage [options] [files...]`
234
+
235
+ 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:
236
+
237
+ | Option/Flag | Default | Description |
238
+ | ----------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
239
+ | `--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. |
240
+ | `-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. |
241
+ | `-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. |
242
+ | `--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. |
243
+ | `--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. |
244
+ | `--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. |
245
+
246
+ ## Full Library Documentation
149
247
 
150
- The collage 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.
248
+ Pixeli also provides functions for every merge. They can be imported like so:
151
249
 
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
250
 
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
251
  ```javascript
252
+ import { gridMerge, masonryMerge, templageMerge, collageMerge } from 'pixeli';
253
+ ```
254
+
255
+ All merge functions have the following signature:
256
+
257
+ ```typescript
258
+ interface MergeCommand<T> {
259
+ (
260
+ imageInputs: sharp.SharpInput[],
261
+ options: T,
262
+ onProgress?: (total: number, completed: number, phase: string): void;
263
+ ): Promise<Buffer>;
264
+ }
265
+ ```
266
+
267
+ 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.
268
+
269
+ The `options` parameter is where merge-specific options are given as an object. Each merge function has their own set of supported options.
270
+
271
+ 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").
272
+
273
+ ⚠️ NOTE ⚠️: The `onProgress` callback will be changed in upcoming versions.
274
+
275
+ 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.
276
+
277
+ ### gridMerge Function Options
278
+
279
+ The `gridMerge` function has the following set of options:
280
+
281
+ | Option | Data Type | Description |
282
+ | ---------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
283
+ | `shuffle` | `boolean` | Whether to randomize the image order before merging. |
284
+ | `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
285
+ | `gap` | `number` | Gap between images in pixels. |
286
+ | `canvasColor` | `Color` | Background color of the output canvas. |
287
+ | `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
288
+ | `borderColor` | `Color` | Color of the border around each image. |
289
+ | `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
290
+ | `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`. |
291
+ | `imageWidth` | `number \| undefined` | Width of each image cell in pixels. If undefined, the median width of the input images is used. |
292
+ | `columns` | `number` | Number of columns in the grid layout. |
293
+ | `caption` | `boolean` | Whether to render captions under images. |
294
+ | `captions` | `string[]` | Caption text for each image, in order. |
295
+ | `captionColor` | `Color` | Text color used for image captions. |
296
+ | `maxCaptionSize` | `number` | Maximum caption font size in pixels. |
297
+
298
+ ### masonryMerge Function Options
299
+
300
+ The `masonryMerge` function has the following set of options:
301
+
302
+ | Option | Data Type | Description |
303
+ | -------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
304
+ | `shuffle` | `boolean` | Whether to randomize the image order before merging. |
305
+ | `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
306
+ | `gap` | `number` | Gap between images in pixels. |
307
+ | `canvasColor` | `Color` | Background color of the output canvas. |
308
+ | `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
309
+ | `borderColor` | `Color` | Color of the border around each image. |
310
+ | `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
311
+ | `rowHeight` | `number \| undefined` | Height of each row in pixels. Defaults to the trimmed median image height if undefined. Only applied in horizontal layouts. |
312
+ | `columnWidth` | `number \| undefined` | Width of each column in pixels. Defaults to the trimmed median image width if undefined. Only applied in vertical layouts. |
313
+ | `canvasWidth` | `number \| undefined` | Width of the entire output canvas in pixels. Required when using horizontal flow. |
314
+ | `canvasHeight` | `number \| undefined` | Height of the entire output canvas in pixels. Required when using vertical flow. |
315
+ | `flow` | `'horizontal' \| 'vertical'` | Orientation of the masonry layout. Determines whether items flow by rows (horizontal) or by columns (vertical). |
316
+ | `hAlign` | `'left' \| 'center' \| 'right' \| 'justified'` | Horizontal alignment of items within each row. Only applied in horizontal layouts. |
317
+ | `vAlign` | `'top' \| 'middle' \| 'bottom' \| 'justified'` | Vertical alignment of items within each column. Only applied in vertical layouts. |
318
+
319
+ ### templateMerge Function Options
320
+
321
+ The `templateMerge` function has the following set of options:
322
+
323
+ | Option | Data Type | Description |
324
+ | -------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
325
+ | `shuffle` | `boolean` | Whether to randomize the image order before merging. |
326
+ | `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
327
+ | `gap` | `number` | Gap between images in pixels. |
328
+ | `canvasColor` | `Color` | Background color of the output canvas. |
329
+ | `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
330
+ | `borderColor` | `Color` | Color of the border around each image. |
331
+ | `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
332
+ | `template` | `Template` | An object definition describing the layout, slots, and canvas configuration used to place images. See [JSON Templates](#json-templates) for more information. |
333
+
334
+ ### collageMerge Function Options
335
+
336
+ The `collageMerge` function has the following set of options:
337
+
338
+ | Option | Data Type | Description |
339
+ | -------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
340
+ | `shuffle` | `boolean` | Whether to randomize the image order before merging. |
341
+ | `cornerRadius` | `number` | Rounded corner radius in pixels applied to each image. |
342
+ | `canvasColor` | `Color` | Background color of the output canvas. |
343
+ | `borderWidth` | `number` | Width of the border around each image in pixels. Borders are drawn internally within each image. |
344
+ | `borderColor` | `Color` | Color of the border around each image. |
345
+ | `format` | `string` | Output image format (e.g., `png`, `jpeg`, `webp`). |
346
+ | `imageWidth` | `number` | Width of each image cell in pixels. If undefined, the median input image width is used. |
347
+ | `aspectRatio` | `string \| number` | Aspect ratio used to calculate image height from width. Examples: `"16:9"`, `"3x2"`, or `1.777`. |
348
+ | `columns` | `number` | Number of columns in the collage grid. |
349
+ | `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. |
350
+ | `overlapPercentage` | `number` | Estimated percentage of overlap between neighboring images. Higher values create a tighter, denser collage. |
351
+ | `rotationRange` | `number` | Maximum absolute rotation angle in degrees. A value of `10` produces a random rotation between `-10°` and `+10°`. |
352
+
353
+ ## Other
354
+
355
+ ### JSON Templates
356
+ JSON templates used with template merge accept a JSON object that defines a grid-based canvas layout and how content occupies it.
357
+
358
+ The layout consists of:
359
+
360
+ - A canvas definition (overall grid size)
361
+ - A list of slots describing how items are placed inside the grid
362
+
363
+ 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.
364
+
365
+ #### canvas
366
+
367
+ The **canvas** object defines the size and structure of the grid:
368
+ ```json
161
369
  {
162
- type: 'object',
163
- required: ['canvas', 'slots'],
164
- properties: {
165
- canvas: {
166
- type: 'object',
167
- required: ['width', 'height', 'columns', 'rows'],
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
- },
370
+ "canvas": {
371
+ "width": 1200,
372
+ "height": 800,
373
+ "columns": 4,
374
+ "rows": 3
375
+ }
192
376
  }
193
377
  ```
194
378
 
195
- The `template.canvas` object defines key properties of the canvas, and the `template.slots` array lists all the slots in which images are to be placed.
379
+ | Field | Type | Description |
380
+ | --------- | ------ | ---------------------------------------------------- |
381
+ | `width` | number | Canvas width in pixels. Must be a positive integer. |
382
+ | `height` | number | Canvas height in pixels. Must be a positive integer. |
383
+ | `columns` | number | Number of grid columns. Must be a positive integer. |
384
+ | `rows` | number | Number of grid rows. Must be a positive integer. |
196
385
 
197
- A slot object takes 4 properties: `col`, `row`, `colSpan`, and `rowSpan`. `col` and `row` specify which column and row to place the image in, while `colSpan` and `rowSpan` define how many units the image should take up horizontally and vertically.
386
+ #### slots
198
387
 
199
- The width of a single unit is equal to canvas width divided by the number of columns, and the height of a single unit is equal to the canvas height divided by the number of rows.
388
+ 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
389
 
201
- For example:
202
390
  ```json
203
- {
204
- "col": 1,
205
- "row": 5,
206
- "colSpan": 3,
207
- "rowSpan": 2
391
+ {
392
+ "slots": [
393
+ { "col": 1, "row": 1, "colSpan": 2, "rowSpan": 1 },
394
+ { "col": 3, "row": 2, "colSpan": 1, "rowSpan": 2 }
395
+ ]
208
396
  }
209
397
  ```
210
- This slot will be placed at the 1st column from the left, at the 5th row from the top. It will span 3 columns, including the one it has been placed in, meaning it will take up column 1, 2, and 3. The same goes for the rows; the slot will take up row 5 and 6.
398
+
399
+ | Field | Type | Description |
400
+ | --------- | ------ | --------------------------------- |
401
+ | `col` | number | Starting column index (1-based). |
402
+ | `row` | number | Starting row index (1-based). |
403
+ | `colSpan` | number | Number of columns the slot spans. |
404
+ | `rowSpan` | number | Number of rows the slot spans. |
405
+
406
+ #### Slot Rules
407
+
408
+ - All values must be positive integers.
409
+ - Slots must fit within the grid:
410
+ ```
411
+ col + colSpan - 1 ≤ columns
412
+ row + rowSpan - 1 ≤ rows
413
+ ```
414
+ - Overlapping slots will be rejected.
415
+ - Slot indices start at 1, not 0.
416
+
417
+ #### Sample JSON Template
211
418
 
212
419
  This is an example of a full JSON template:
213
420
  ```json
@@ -217,8 +424,6 @@ This is an example of a full JSON template:
217
424
  "height": 1600,
218
425
  "columns": 3,
219
426
  "rows": 6,
220
- "gap": 12,
221
- "background": "#000"
222
427
  },
223
428
  "slots": [
224
429
  { "col": 1, "row": 1, "colSpan": 2, "rowSpan": 2 },
@@ -233,8 +438,77 @@ This is an example of a full JSON template:
233
438
 
234
439
  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
440
 
236
- ## License
237
- This project is licensed under the [MIT License](./LICENSE).
441
+ ### All Supported Input Formats
442
+
443
+ - ***webp***
444
+ - ***gif***
445
+ - ***jpeg***
446
+ - ***jpg***
447
+ - ***png***
448
+ - ***tiff***
449
+ - ***avif***
450
+ - ***svg***
451
+
452
+ ### All Supported Output Formats
453
+
454
+ - ***webp***
455
+ - ***gif***
456
+ - ***jpeg***
457
+ - ***jpg***
458
+ - ***png***
459
+ - ***tiff***
460
+ - ***avif***
461
+
462
+ ### Pixel Limits
463
+
464
+ 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:
465
+
466
+ | Format | Typical Extension(s) | Max Width × Height | Notes |
467
+ | ---------------------------- | -------------------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
468
+ | **JPEG / JPG** | `.jpg`, `.jpeg` | **65,535 × 65,535 px** | Standard limit from JFIF/JPEG. No alpha. |
469
+ | **PNG** | `.png` | **~2,147,483,647 × 2,147,483,647 px** | Theoretical spec limit; real-world memory limits apply. Supports transparency. |
470
+ | **WebP** | `.webp` | **16,383 × 16,383 px** | Format standard limit — smaller than PNG/JPEG. |
471
+ | **GIF** | `.gif` | **65,536 × 65,536 px** | - |
472
+ | **BMP** | `.bmp` | **32,767×32,767 or ~2,147,483,647×2,147,483,647 px** | Depends on version/fields. |
473
+ | **TIFF** | `.tif`, `.tiff` | **4,294,967,295 × 4,294,967,295 px** (theoretical) | Very large; may be limited by software or memory. |
474
+
475
+ ### Error Handling
476
+ All errors produced by this library are instances of the `MergeError` class, which extends the `Error` class.
477
+
478
+ In addition to the inherited `message` property, the `MergeError` class also has a `context` object parameter attached to it, where there is a `type` and an optional `cause` property. Consider the following:
479
+
480
+ ```typescript
481
+ throw new MergeError("Some error has occurred", {
482
+ type: 'internal',
483
+ cause: 'helper "trimmedMedian" failed'
484
+ });
485
+ ```
238
486
 
239
- ## Other
240
- This project was submitted to [Hack Club](https://hackclub.com/), a group consisting of over 100,000 teen hackers from around the world who work on cool projects and get to participate in awesome programs like [Midnight](https://midnight.hackclub.com).
487
+ The `cause` property is only used when an internal error has occurred, meaning that there is something wrong with the API.
488
+
489
+ The `type` property can be one of the following:
490
+ - `validation`: One of the options provided to the merge function is incorrect or is required but not provided.
491
+ - `image`: An invalid, corrupt, or empty image input list has been provided.
492
+ - `internal`: An error with the interal library. Should not occur.
493
+
494
+
495
+ ### Colors and Transparency
496
+
497
+ #### CLI
498
+ Hex colors are used in the CLI.
499
+
500
+ 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.
501
+
502
+ 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.
503
+
504
+ #### Library
505
+ Colors in the library functions are either objects or hex values. The `Color` type is used to describe colors:
506
+
507
+ ```typescript
508
+ type Color = { r: number; g: number; b: number; alpha: number } | string;
509
+ ```
510
+
511
+ 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.
512
+
513
+ ## License
514
+ This project is licensed under the [MIT License](./LICENSE).
@@ -0,0 +1,2 @@
1
+ declare const collageCommand: import("commander").Command;
2
+ export default collageCommand;