feat: add lut node script, renders, and examples

This commit is contained in:
ozwaldorf 2023-05-05 13:28:47 -04:00
parent 31bee1a219
commit e63effa054
No known key found for this signature in database
34 changed files with 97 additions and 0 deletions

55
lut/apply.sh Executable file
View file

@ -0,0 +1,55 @@
#!/bin/bash
set -e
# ensure src is where the script is located, even if symlinked
src="$( cd -- "$( dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || ${BASH_SOURCE[0]})" )" &> /dev/null && pwd )/src"
print_usage() {
name=`basename $0`
cat <<EOF
Usage: $name -i <image1> ... [args]
-i image : Image to apply LUT to, can be repeated
-f flavor : Flavor to apply, can be repeated. Defaults to all
-n noise : LUT Noise level (0-4). Defaults to 2
EOF
}
noise="2"
images=""
flavors=""
while getopts ':f:i:n:' flag; do
case "$flag" in
n)
if [[ $OPTARG -gt 4 ]]; then
echo "Invalid noise level (0-4)"
exit 1
else
noise=$OPTARG
fi
;;
f) flavors="$flavors $OPTARG" ;;
i) images="$images `realpath $OPTARG`" ;;
*) print_usage
exit 1 ;;
esac
done
if [[ "$images" == "" ]]; then
print_usage
fi
if [[ "$flavors" == "" ]]; then
flavors="Oled Mocha Macchiato Frappe Latte"
fi
for file in $images; do
echo "Performing magick on `basename $file` (noise: $noise)"
for flavor in $flavors; do
printf "$flavor ..."
out="${file%%.*}-${flavor}.png"
magick $file "$src/noise_$noise/Catppuccin ${flavor}.png" -hald-clut "$out"
printf "\r$flavor ✓ ($out)\n"
done
done

BIN
lut/example/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

@ -0,0 +1,42 @@
import { exec } from "child_process";
import url from "url";
import path from "path";
import fs from "fs";
import util from "util";
import { variants } from "@catppuccin/palette";
const root = path.resolve(
url.fileURLToPath(new URL(".", import.meta.url)),
"..",
"..",
"dist"
);
const generateLut = async (name, out) => {
for (let i = 0; i <= 4; i++) {
fs.mkdirSync(path.join(root, `lut/noise_${i}`), { recursive: true });
process.stdout.clearLine(0);
process.stdout.cursorTo(0);
process.stdout.write(`${name}: [${i + 1}/5]`);
const cmd = `convert HALD:8 -duplicate 512 -attenuate ${i} +noise Gaussian -quantize LAB +dither -remap "${root}/png/${name}.png" -evaluate-sequence Mean "${root}/../lut/noise_${i}/${name}.png"`;
await util.promisify(exec)(cmd);
}
process.stdout.clearLine(0);
process.stdout.cursorTo(0);
console.log(`${name}: done`);
};
console.log("Generating Hald CLUTs...")
const flavors = Object.keys(variants);
for (let i = 0; i < flavors.length; i++) {
const name = flavors[i];
// formatted "pretty" name, Catppuccin <Flavor>
const pname = `Catppuccin ${name.charAt(0).toUpperCase() + name.slice(1)}`;
await generateLut(pname);
}