From d3c87904821e1da143483dc5ca62554ba7d3ff96 Mon Sep 17 00:00:00 2001 From: Chuck Dries Date: Fri, 21 Oct 2022 00:25:58 -0700 Subject: [PATCH] add tahoe pic and mildly refactor processcolors --- data/gallery/_DSC9811.jpg | 3 +++ gatsby-node.ts | 31 ++++++++++++++----------------- 2 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 data/gallery/_DSC9811.jpg diff --git a/data/gallery/_DSC9811.jpg b/data/gallery/_DSC9811.jpg new file mode 100644 index 0000000..74ee24a --- /dev/null +++ b/data/gallery/_DSC9811.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37d33118ab54006ceddb913f3afe6dce7c7904991ba4dea5a04651f4c89e23b0 +size 584378 diff --git a/gatsby-node.ts b/gatsby-node.ts index 000d5b5..754570d 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -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,24 +46,20 @@ 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(); - } } + 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); - } + 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 @@ -177,7 +174,7 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({ .toBuffer(); const vibrantData = await Vibrant.from(resizedImage) - .quality(1) + // .quality(1) .getPalette(); createNodeField({