From 3efcff153ff2120ed2095acc07c9119dc2efedae Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 9 Mar 2022 14:31:51 +0100 Subject: [PATCH] Add a way to make transparent PNGs opaque. --- source/2022-03-06.ts | 1 + source/2022-03-07.ts | 1 + source/2022-03-08.ts | 1 + source/driftingnebula.ts | 17 ++++++++++++++++- source/project.ts | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/2022-03-06.ts b/source/2022-03-06.ts index e0cfb48..c3c3057 100644 --- a/source/2022-03-06.ts +++ b/source/2022-03-06.ts @@ -56,6 +56,7 @@ const project: Project = { midpoint: 0.6, }), ], + resetAlpha: false, resolution: { width, height, diff --git a/source/2022-03-07.ts b/source/2022-03-07.ts index 5a9e68b..469af92 100644 --- a/source/2022-03-07.ts +++ b/source/2022-03-07.ts @@ -51,6 +51,7 @@ const project: Project = { }), new Generic('gegl:median-blur'), ], + resetAlpha: false, resolution: { width, height, diff --git a/source/2022-03-08.ts b/source/2022-03-08.ts index a628973..9432d4a 100644 --- a/source/2022-03-08.ts +++ b/source/2022-03-08.ts @@ -33,6 +33,7 @@ const project: Project = { shape: 'circle', }), ], + resetAlpha: false, resolution: { width, height, diff --git a/source/driftingnebula.ts b/source/driftingnebula.ts index cfa8949..82606bb 100644 --- a/source/driftingnebula.ts +++ b/source/driftingnebula.ts @@ -18,7 +18,13 @@ async function main(): Promise { const projects: Project[] = [d2022_03_06, d2022_03_07, d2022_03_08]; - for (const {createInputImage, name, operations, resolution} of projects) { + for (const { + createInputImage, + name, + operations, + resolution, + resetAlpha, + } of projects) { const dataStart = performance.now(); const {width, height} = resolution; @@ -74,6 +80,15 @@ async function main(): Promise { ...graph, ]); + if (resetAlpha) { + await execa('convert', [ + fullOutputFile, + '-alpha', + 'Off', + fullOutputFile, + ]); + } + console.log(`* Writing ${compressedFile}`); await execa('magick', [ 'convert', diff --git a/source/project.ts b/source/project.ts index c21ad87..9e93adc 100644 --- a/source/project.ts +++ b/source/project.ts @@ -4,6 +4,7 @@ export default interface Project { createInputImage: boolean; name: string; operations: Array>; + resetAlpha: boolean; resolution: { height: number; width: number;