From cb4c1ecd1973765dc5844958e3050740ea403982 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Sat, 21 Oct 2023 22:24:21 +0900 Subject: [PATCH 1/2] Enable PNG image transparency --- src/converter.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/converter.ts b/src/converter.ts index 32a90330..78d2bfeb 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -392,6 +392,13 @@ export class Converter { await render() await page.emulateMediaType('print') + if (opts.type === ConvertType.png) { + // Enable transparency + await page.addStyleTag({ + content: ':root,body { background:transparent !important; }', + }) + } + const screenshot = async (pageNumber = 1) => { const clip = { x: 0, @@ -406,7 +413,11 @@ export class Converter { type: 'jpeg', }) - return await page.screenshot({ clip, type: 'png' }) + return await page.screenshot({ + clip, + omitBackground: true, + type: 'png', + }) } if (opts.pages) { From 3b8eb385a2018288ce463de9fc6bcd1084e14336 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Sat, 28 Oct 2023 19:10:59 +0900 Subject: [PATCH 2/2] [ci skip] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc41e01..641765ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Upgrade Marp Core to [v3.9.0](https://github.com/marp-team/marp-core/releases/v3.9.0) ([#557](https://github.com/marp-team/marp-cli/pull/557)) - Upgrade dependent packages to the latest versions ([#557](https://github.com/marp-team/marp-cli/pull/557)) +### Fixed + +- Enable PNG image transparency ([#555](https://github.com/marp-team/marp-cli/issues/555), [#556](https://github.com/marp-team/marp-cli/pull/556)) + ## v3.3.1 - 2023-10-01 ### Fixed