From b45c1981ccfcf39c71de3fda565eea844f391db1 Mon Sep 17 00:00:00 2001 From: Ian Foster Date: Wed, 10 Nov 2021 12:14:02 -0800 Subject: [PATCH] add support for changing the color mode --- README.md | 1 + config.js | 1 + index.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 280174d..82c48be 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Home Assistant related stuff: | `ROTATION` | `0` | no | yes | Rotation of image in degrees, e.g. use 90 or 270 to render in landscape | | `SCALING` | `1` | no | yes | Scaling factor, e.g. `1.5` to zoom in or `0.75` to zoom out | | `GRAYSCALE_DEPTH` | `8` | no | yes | Ggrayscale bit depth your kindle supports | +| `COLOR_MODE` | `GrayScale` | no | yes | ColorMode to use, ex: `GrayScale`, or `TrueColor`. | **\* Array** means that you can set `HA_SCREENSHOT_URL_2`, `HA_SCREENSHOT_URL_3`, ... `HA_SCREENSHOT_URL_n` to render multiple pages within the same instance. If you use `HA_SCREENSHOT_URL_2`, you can also set `ROTATION_2=180`. If there is no `ROTATION_n` set, then `ROTATION` will be used as a fallback. diff --git a/config.js b/config.js index 322d8cc..8fcefe7 100644 --- a/config.js +++ b/config.js @@ -25,6 +25,7 @@ function getPagesConfig() { width: getEnvironmentVariable("RENDERING_SCREEN_WIDTH", suffix) || 600, }, grayscaleDepth: getEnvironmentVariable("GRAYSCALE_DEPTH", suffix) || 8, + colorMode: getEnvironmentVariable("COLOR_MODE", suffix) || "GrayScale", rotation: getEnvironmentVariable("ROTATION", suffix) || 0, scaling: getEnvironmentVariable("SCALING", suffix) || 1, }); diff --git a/index.js b/index.js index 781a2a6..10f1901 100644 --- a/index.js +++ b/index.js @@ -212,7 +212,7 @@ function convertImageToKindleCompatiblePngAsync( imageMagick: config.useImageMagick === true, }) .rotate("white", pageConfig.rotation) - .type("GrayScale") + .type(pageConfig.colorMode) .bitdepth(pageConfig.grayscaleDepth) .write(outputPath, (err) => { if (err) {