Erstelle Aktuelles-Meldungen und Flyer-Varianten
Deploy / scheduled-rebuild-dev (push) Skipped
Deploy / rollback-dev (push) Skipped
Deploy / validate-dispatch (push) Successful in 1m17s
Deploy / changes (push) Successful in 24s
Deploy / secret-scan (push) Successful in 9s
Deploy / security-deps (push) Failing after 22s
Deploy / context (push) Successful in 0s
Deploy / app-image (push) Canceled after 0s
Deploy / deploy-dev (push) Canceled after 0s
Deploy / deploy-master (push) Canceled after 0s
Deploy / scheduled-rebuild-master (push) Canceled after 0s
Deploy / rollback-master (push) Canceled after 0s
Deploy / app-quality (push) Canceled after 4m59s
Deploy / scheduled-rebuild-dev (push) Skipped
Deploy / rollback-dev (push) Skipped
Deploy / validate-dispatch (push) Successful in 1m17s
Deploy / changes (push) Successful in 24s
Deploy / secret-scan (push) Successful in 9s
Deploy / security-deps (push) Failing after 22s
Deploy / context (push) Successful in 0s
Deploy / app-image (push) Canceled after 0s
Deploy / deploy-dev (push) Canceled after 0s
Deploy / deploy-master (push) Canceled after 0s
Deploy / scheduled-rebuild-master (push) Canceled after 0s
Deploy / rollback-master (push) Canceled after 0s
Deploy / app-quality (push) Canceled after 4m59s
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import sharp from "sharp";
|
||||
|
||||
const imageDir = path.resolve(import.meta.dirname, "../public/images/events");
|
||||
const files = await fs.readdir(imageDir);
|
||||
|
||||
for (const file of files.filter((name) => /\.jpe?g$/i.test(name))) {
|
||||
const sourcePath = path.join(imageDir, file);
|
||||
const baseName = path.basename(file, path.extname(file));
|
||||
const jpeg = await fs.readFile(sourcePath);
|
||||
const { width, height } = await sharp(jpeg).metadata();
|
||||
if (!width || !height) throw new Error(`Bildabmessungen fehlen: ${file}`);
|
||||
|
||||
const avifPath = path.join(imageDir, `${baseName}.avif`);
|
||||
const svgPath = path.join(imageDir, `${baseName}.svg`);
|
||||
await sharp(jpeg).avif({ quality: 75 }).toFile(avifPath);
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><image width="${width}" height="${height}" href="data:image/jpeg;base64,${jpeg.toString("base64")}" /></svg>\n`;
|
||||
await fs.writeFile(svgPath, svg);
|
||||
console.log(`[images:events] ${file} → ${path.basename(avifPath)}, ${path.basename(svgPath)}`);
|
||||
}
|
||||
Reference in New Issue
Block a user