Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions cli/src/ThumbnailGridGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stream } from "stream";
import { storage } from "./FirebaseUtil";
import { meilisearch } from "./SearchManager";
import sharp from 'sharp';
import Jimp from 'jimp';
import chunk from "chunk";

/**
Expand All @@ -28,36 +28,23 @@ export default async function generateThumbnailGrid(width: number, height: numbe
const thumbWidth = 64;
const thumbHeight = 36;

const image = sharp({
create: {
width: thumbWidth * width,
height: thumbHeight * height,
channels: 4,
background: { r: 0, g: 0, b: 0, alpha: 0 },
}
});
const image = await new Jimp(thumbWidth * width, thumbHeight * height, 0x00000000);

// Add each thumbnail to the image.
const composites: sharp.OverlayOptions[] = [];
for (let i = 0; i < numThumbnails; i++) {
const x = i % width;
const y = Math.floor(i / width);

const img = thumbnails[i];
if (img === null) continue;

composites.push({
input: img,
left: x * thumbWidth,
top: y * thumbHeight,
});
const imgJimp = await Jimp.read(img);
image.composite(imgJimp, x * thumbWidth, y * thumbHeight);
}

image.composite(composites);

// Save the image to the output file.
console.log('Saving thumbnail grid...');
await image.png().toFile(outputFilePath);
await image.writeAsync(outputFilePath);

console.log('Thumbnail grid saved.');
}
Expand Down
6 changes: 3 additions & 3 deletions data/meilisearch-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"host": "https://search.makercentral.io",
"apiKey": "ec054708252e1af3970c061dfcb6ca95b9f5b36c4ca54c15bd4f577131d3a9fe"
}
"host": "https://meilisearch.wizul.us",
"apiKey": "d836faf72e4ba8d5716894bd2f3d23a3d75a07b43674e2fc3343241588ed5719"
}
Loading