another imgs
Za Šířka: | Výška: | Velikost: 3.4 KiB |
Za Šířka: | Výška: | Velikost: 8.1 KiB |
Za Šířka: | Výška: | Velikost: 15 KiB |
Za Šířka: | Výška: | Velikost: 25 KiB |
Za Šířka: | Výška: | Velikost: 44 KiB |
Za Šířka: | Výška: | Velikost: 3.4 KiB |
Za Šířka: | Výška: | Velikost: 6.8 KiB |
Za Šířka: | Výška: | Velikost: 12 KiB |
Za Šířka: | Výška: | Velikost: 54 KiB |
Za Šířka: | Výška: | Velikost: 1.5 KiB |
Za Šířka: | Výška: | Velikost: 2.8 KiB |
Za Šířka: | Výška: | Velikost: 4.6 KiB |
Za Šířka: | Výška: | Velikost: 4.0 KiB |
Za Šířka: | Výška: | Velikost: 2.6 KiB |
Za Šířka: | Výška: | Velikost: 5.7 KiB |
Za Šířka: | Výška: | Velikost: 9.7 KiB |
Za Šířka: | Výška: | Velikost: 8.7 KiB |
Za Šířka: | Výška: | Velikost: 1.3 KiB |
Za Šířka: | Výška: | Velikost: 2.6 KiB |
Za Šířka: | Výška: | Velikost: 4.2 KiB |
Za Šířka: | Výška: | Velikost: 3.9 KiB |
Za Šířka: | Výška: | Velikost: 5.1 KiB |
Za Šířka: | Výška: | Velikost: 13 KiB |
Za Šířka: | Výška: | Velikost: 25 KiB |
Za Šířka: | Výška: | Velikost: 32 KiB |
Za Šířka: | Výška: | Velikost: 2.7 KiB |
Za Šířka: | Výška: | Velikost: 7.6 KiB |
Za Šířka: | Výška: | Velikost: 17 KiB |
Za Šířka: | Výška: | Velikost: 25 KiB |
Za Šířka: | Výška: | Velikost: 8.9 KiB |
Za Šířka: | Výška: | Velikost: 26 KiB |
Za Šířka: | Výška: | Velikost: 47 KiB |
Za Šířka: | Výška: | Velikost: 36 KiB |
Za Šířka: | Výška: | Velikost: 2.8 KiB |
Za Šířka: | Výška: | Velikost: 6.3 KiB |
Za Šířka: | Výška: | Velikost: 12 KiB |
Za Šířka: | Výška: | Velikost: 35 KiB |
Za Šířka: | Výška: | Velikost: 2.1 KiB |
Za Šířka: | Výška: | Velikost: 4.4 KiB |
Za Šířka: | Výška: | Velikost: 8.0 KiB |
Za Šířka: | Výška: | Velikost: 8.5 KiB |
|
@ -298,10 +298,14 @@ class DeConf_Collection {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const longer = info.width > info.height ? 'w' : 'h'
|
const longer = info.width > info.height ? "w" : "h";
|
||||||
const ratio = longer === 'h' ? (info.width / info.height) : (info.height / info.width);
|
const ratio = longer === "h"
|
||||||
|
? (info.width / info.height)
|
||||||
|
: (info.height / info.width);
|
||||||
for (const sz of thumbSizes) {
|
for (const sz of thumbSizes) {
|
||||||
const pxs = longer === 'h' ? [ sz, Math.round(sz / ratio) ] : [ Math.round(sz / ratio), sz];
|
const pxs = longer === "h"
|
||||||
|
? [sz, Math.round(sz / ratio)]
|
||||||
|
: [Math.round(sz / ratio), sz];
|
||||||
//console.log(`size=${sz} px_orig=${[info.width, info.height]} px=${pxs}`)
|
//console.log(`size=${sz} px_orig=${[info.width, info.height]} px=${pxs}`)
|
||||||
//console.log(info.width, info.height, ratio, sz, cheight)
|
//console.log(info.width, info.height, ratio, sz, cheight)
|
||||||
const szDest = [this.dir, fn.replace(/\.([^\.]+)$/, `-${sz}px.op.webp`)]
|
const szDest = [this.dir, fn.replace(/\.([^\.]+)$/, `-${sz}px.op.webp`)]
|
||||||
|
@ -363,26 +367,34 @@ class DeConf_Collection {
|
||||||
const writeImage = async (fn, outDir, fnRename = null) => {
|
const writeImage = async (fn, outDir, fnRename = null) => {
|
||||||
const srcFile = [this.dir, fn].join("/");
|
const srcFile = [this.dir, fn].join("/");
|
||||||
if (await exists(srcFile)) {
|
if (await exists(srcFile)) {
|
||||||
const outFile = [ outDir, fnRename || posix.basename(fn) ].join("/");
|
const outFile = [outDir, fnRename || posix.basename(fn)].join("/");
|
||||||
await _fileCopy(srcFile, outFile);
|
await _fileCopy(srcFile, outFile);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
const writeImageBundle = async (src, outDir) => {
|
const writeImageBundle = async (src, outDir) => {
|
||||||
await ensureDir(outDir);
|
await ensureDir(outDir);
|
||||||
//await writeImage(src, outDir)
|
//await writeImage(src, outDir)
|
||||||
//await writeImage(src.replace(/\.(.+)$/, '.op.webp'), outDir, posix.basename(src).replace(/\.(.+)$/, `.webp`))
|
//await writeImage(src.replace(/\.(.+)$/, '.op.webp'), outDir, posix.basename(src).replace(/\.(.+)$/, `.webp`))
|
||||||
await writeImage(src.replace(/\.(.+)$/, '-500px.op.webp'), outDir, posix.basename(src).replace(/\.(.+)$/, `.webp`))
|
await writeImage(
|
||||||
|
src.replace(/\.(.+)$/, "-500px.op.webp"),
|
||||||
|
outDir,
|
||||||
|
posix.basename(src).replace(/\.(.+)$/, `.webp`),
|
||||||
|
);
|
||||||
for (const sz of thumbSizes) {
|
for (const sz of thumbSizes) {
|
||||||
await writeImage(src.replace(/\.(.+)$/, `-${sz}px.op.webp`), outDir, posix.basename(src).replace(/\.(.+)$/, `_${sz}px.webp`))
|
await writeImage(
|
||||||
|
src.replace(/\.(.+)$/, `-${sz}px.op.webp`),
|
||||||
|
outDir,
|
||||||
|
posix.basename(src).replace(/\.(.+)$/, `_${sz}px.webp`),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
for (const asset of this.assets) {
|
for (const asset of this.assets) {
|
||||||
if (!x[asset]) continue;
|
if (!x[asset]) continue;
|
||||||
|
|
||||||
const outDir = [outputDir, this.id].join("/")
|
const outDir = [outputDir, this.id].join("/");
|
||||||
await emptyDir(outDir)
|
await emptyDir(outDir);
|
||||||
await writeImageBundle(x[asset], outDir)
|
await writeImageBundle(x[asset], outDir);
|
||||||
const fnOut = [this.id, x[asset].replace(/\.[^.]+$/, '.webp')].join("/");
|
const fnOut = [this.id, x[asset].replace(/\.[^.]+$/, ".webp")].join("/");
|
||||||
const url = [publicUrl, fnOut].join("/");
|
const url = [publicUrl, fnOut].join("/");
|
||||||
this.data.index[asset] = url;
|
this.data.index[asset] = url;
|
||||||
}
|
}
|
||||||
|
@ -394,16 +406,16 @@ class DeConf_Collection {
|
||||||
const outDir = [outputDir, this.id, "photos", "speakers"].join("/");
|
const outDir = [outputDir, this.id, "photos", "speakers"].join("/");
|
||||||
for (const sp of speakersCol) {
|
for (const sp of speakersCol) {
|
||||||
if (!sp.photo) continue;
|
if (!sp.photo) continue;
|
||||||
await writeImageBundle(sp.photo, outDir)
|
await writeImageBundle(sp.photo, outDir);
|
||||||
|
|
||||||
sp.photoUrl = [
|
sp.photoUrl = [
|
||||||
publicUrl,
|
publicUrl,
|
||||||
this.id,
|
this.id,
|
||||||
"photos",
|
"photos",
|
||||||
"speakers",
|
"speakers",
|
||||||
posix.basename(sp.photo).replace(/\.[^.]+$/, '.webp'),
|
posix.basename(sp.photo).replace(/\.[^.]+$/, ".webp"),
|
||||||
].join("/");
|
].join("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ if (Deno.args[0]) {
|
||||||
const ev = entry.data.events.find((e) => e.id === Deno.args[0]);
|
const ev = entry.data.events.find((e) => e.id === Deno.args[0]);
|
||||||
await ev.optimizeImages();
|
await ev.optimizeImages();
|
||||||
} else {
|
} else {
|
||||||
for (const type of ["events", "places", "benefits", "media-partners"]) {
|
for (const type of Object.keys(entry.colMapper)) {
|
||||||
for (const item of entry.data[type]) {
|
for (const item of entry.data[type]) {
|
||||||
if (item.data.index.hidden) {
|
if (item.data.index.hidden) {
|
||||||
continue;
|
continue;
|
||||||
|
|