@visualizevalue/img-grid 0.1.0 → 0.1.1
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/dist/index.js +4 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,15 +8,17 @@ const sharp_1 = __importDefault(require("sharp"));
|
|
|
8
8
|
async function grid(images, opts = {}) {
|
|
9
9
|
const highlightIds = new Set(opts.highlight ?? []);
|
|
10
10
|
const concurrency = opts.concurrency ?? 10;
|
|
11
|
-
const highlightScale = 2;
|
|
12
11
|
const maxWidth = opts.maxWidth ?? 1920;
|
|
13
12
|
const highlightedImages = images.filter((img) => img.id && highlightIds.has(img.id));
|
|
14
13
|
const normalImages = images.filter((img) => !highlightIds.has(img.id ?? ''));
|
|
14
|
+
const highlightScale = highlightedImages.length ? 2 : 1;
|
|
15
15
|
const totalCells = normalImages.length + highlightedImages.length * highlightScale * highlightScale;
|
|
16
16
|
const gridSize = Math.ceil(Math.sqrt(totalCells));
|
|
17
17
|
const cellSize = Math.floor(maxWidth / gridSize);
|
|
18
18
|
const highlightedCellSize = cellSize * highlightScale;
|
|
19
|
-
const gridWidth =
|
|
19
|
+
const gridWidth = totalCells === 1 || Math.sqrt(totalCells) % 2 === 0
|
|
20
|
+
? gridSize
|
|
21
|
+
: Math.ceil(Math.sqrt(totalCells * 1.5));
|
|
20
22
|
const gridHeight = gridSize * highlightScale;
|
|
21
23
|
const grid = Array(gridHeight)
|
|
22
24
|
.fill(0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visualizevalue/img-grid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Generate a PNG grid from image URLs (and highlight images).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"packageManager": "npm@11.4.0",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"format": "prettier --write",
|
|
16
|
+
"format": "prettier . --write",
|
|
17
17
|
"prepublishOnly": "npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|