diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-04-26 03:30:53 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-26 03:30:53 -0600 |
| commit | 6eb9e43b431b8192c2196293becbbab827204894 (patch) | |
| tree | 4a10ca4e7ea72e7d75b36ebf7c6565f88727b764 | |
| parent | d3aea36f476046a9923f225adc4cea3c1cb0ceeb (diff) | |
resolves #1687 add asciidoctor/pdf/nogmagick script to prevent Gmagick from handling PNG images (PR #2078)
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/nogmagick.rb | 6 | ||||
| -rw-r--r-- | spec/cli_spec.rb | 10 | ||||
| -rw-r--r-- | spec/fixtures/interlaced-png.adoc | 1 |
4 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index e5e344d6..b79ea87c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,7 @@ Enhancements:: * pass `part`, `chapterlike`, and `hidden` options to `arrange_section` method * add support for `background-color` property on caption (#1995) * add support for image-based icons, resolved from `iconsdir` and having the `icontype` file extension (#1770) +* add `asciidoctor/pdf/nogmagick` script to prevent Gmagick from handling PNG images (#1687) Bug Fixes:: diff --git a/lib/asciidoctor/pdf/nogmagick.rb b/lib/asciidoctor/pdf/nogmagick.rb new file mode 100644 index 00000000..646d44a9 --- /dev/null +++ b/lib/asciidoctor/pdf/nogmagick.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +if defined? GMagick::Image + Prawn.image_handler.unregister Gmagick + Prawn.image_handler.register! Prawn::Images::PNG +end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 303019f0..706b5a7a 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -65,6 +65,16 @@ describe 'asciidoctor-pdf' do end end + context 'nogmagick' do + it 'should unregister Gmagick handler for PNG images if asciidoctor/pdf/nogmagick is required', cli: true do + out, err, res = run_command asciidoctor_pdf_bin, '-D', output_dir, '-r', 'asciidoctor/pdf/nogmagick', (fixture_file 'interlaced-png.adoc'), use_bundler: true + (expect out).to be_empty + (expect err).not_to be_empty + (expect err).to include 'PNG uses unsupported interlace method' + (expect res.exitstatus).to be 0 + end + end + context 'pdfmark' do it 'should generate pdfmark file if pdfmark attribute is set', cli: true do out, err, res = run_command asciidoctor_pdf_bin, '-D', output_dir, '-a', 'pdfmark', (fixture_file 'book.adoc') diff --git a/spec/fixtures/interlaced-png.adoc b/spec/fixtures/interlaced-png.adoc new file mode 100644 index 00000000..dee722e4 --- /dev/null +++ b/spec/fixtures/interlaced-png.adoc @@ -0,0 +1 @@ +image::interlaced.png[pdfwidth=100%] |
