// import ColorThief from 'colorthief' import sharp from 'sharp' import Prevvy from 'prevvy' import path from 'path' import { getTmpFile } from './utils.js'; export async function getProminentColor(imageFile) { const { dominant } = await sharp(imageFile).stats(); const { r, g, b } = dominant; return rgbToHex(r, g, b) } export function rgbToHex(r, g, b) { return "#" + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1); } export async function getStoryboard(imageFileOrUrl) { let base = path.basename(imageFileOrUrl) let outputImagePath = getTmpFile(base) let options = { input: imageFileOrUrl, output: outputImagePath, width: 265, cols: 5, rows: 5 }; let prevvy = new Prevvy(options) await prevvy.generate() return outputImagePath }