Skip to content

Commit d0520cc

Browse files
authored
Merge pull request #556 from marp-team/enable-png-transparency
Enable PNG image transparency
2 parents a82d8f5 + 3b8eb38 commit d0520cc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
- 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))
99
- Upgrade dependent packages to the latest versions ([#557](https://github.com/marp-team/marp-cli/pull/557))
1010

11+
### Fixed
12+
13+
- Enable PNG image transparency ([#555](https://github.com/marp-team/marp-cli/issues/555), [#556](https://github.com/marp-team/marp-cli/pull/556))
14+
1115
## v3.3.1 - 2023-10-01
1216

1317
### Fixed

src/converter.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,13 @@ export class Converter {
392392
await render()
393393
await page.emulateMediaType('print')
394394

395+
if (opts.type === ConvertType.png) {
396+
// Enable transparency
397+
await page.addStyleTag({
398+
content: ':root,body { background:transparent !important; }',
399+
})
400+
}
401+
395402
const screenshot = async (pageNumber = 1) => {
396403
const clip = {
397404
x: 0,
@@ -406,7 +413,11 @@ export class Converter {
406413
type: 'jpeg',
407414
})
408415

409-
return await page.screenshot({ clip, type: 'png' })
416+
return await page.screenshot({
417+
clip,
418+
omitBackground: true,
419+
type: 'png',
420+
})
410421
}
411422

412423
if (opts.pages) {

0 commit comments

Comments
 (0)