add tahoe pic and mildly refactor processcolors

This commit is contained in:
Chuck Dries 2022-10-21 00:25:58 -07:00
parent 87cb5d6525
commit d3c8790482
No known key found for this signature in database
GPG Key ID: A00B7AEAE1DC5BE6
2 changed files with 17 additions and 17 deletions

BIN
data/gallery/_DSC9811.jpg (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -8,6 +8,7 @@ import * as R from "ramda";
import exifr from "exifr";
import sharp from "sharp";
import { Palette } from "node-vibrant/lib/color";
import { performance } from "perf_hooks";
// const path = require("path");
// const Vibrant = require("node-vibrant");
@ -45,25 +46,21 @@ function processColors(vibrantData: Palette, imagePath: string) {
badContrast(DarkVibrant, LightMuted)
) {
DarkVibrant = DarkVibrant.darken();
}
if (badContrast(DarkVibrant, Vibrant)) {
Vibrant = Vibrant.brighten();
}
if (badContrast(DarkVibrant, Vibrant)) {
Vibrant = Vibrant.brighten();
}
}
// second pass - first doesn't always do enough
if (
badContrast(DarkVibrant, Vibrant) ||
badContrast(DarkVibrant, LightMuted)
) {
if (badContrast(DarkVibrant, Vibrant)) {
Vibrant = Vibrant.brighten(2);
}
if (badContrast(DarkVibrant, LightMuted)) {
LightMuted = LightMuted.brighten(2);
}
}
// only used for hover styles, so we should give it a shot but it's not a huge deal if it's not very legible
if (badContrast(Muted, LightMuted)) {
@ -177,7 +174,7 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({
.toBuffer();
const vibrantData = await Vibrant.from(resizedImage)
.quality(1)
// .quality(1)
.getPalette();
createNodeField({