docker-asciidoctor icon indicating copy to clipboard operation
docker-asciidoctor copied to clipboard

Add prawn-gmagick gem

Open mojavelinux opened this issue 5 years ago • 7 comments

The prawn-gmagick gem is a drop-in replacement for the image processing in Asciidoctor PDF that uses GraphicsMagick under the covers. It has the benefit of making PDF conversion of documents containing images substantially faster. Image decoding in pure Ruby is quite slow, so this gem delegates the work to GraphicsMagick to speed it up. It also adds support for more image formats, like GIF. The downside is that it also requires the GraphicsMagick package to be installed. If it doesn't add too much to the size of the image (at least the box image), I think it is well worth adding.

See https://github.com/asciidoctor/asciidoctor-pdf#supporting-additional-image-file-formats

mojavelinux avatar Jan 24 '20 08:01 mojavelinux

Looking forward to this, PDF conversion can be sometimes significantly slow :smile:

bcouetil avatar Jan 28 '20 16:01 bcouetil

While writing tests, I've noticed that prawn-gmagick can mess up the palette of some PNGs. I'm not sure how prevalent this problem is, but we may need to provide an escape hatch (in Asciidoctor PDF) so it doesn't get automatically loaded if it is a real problem.

mojavelinux avatar Jan 28 '20 20:01 mojavelinux

In a container of this image, prawn-gmagick can be installed as follows:

apk add graphicsmagick-dev ruby-dev musl-dev gcc
gem install prawn-gmagick

As documented at https://github.com/asciidoctor/asciidoctor-pdf#supporting-additional-image-file-formats, asciidoctor-pdf will then automatically use that gem for embedding images.

das-g avatar Apr 22 '20 13:04 das-g

Tried to embed image in PDF. Source is a URL (e.g. https://img.shields.io/badge/Status-Open-red). But get the warning "asciidoctor: WARNING: could not embed image: /tmp/image-20200813-1-1h5my3o; image file is an unrecognised format; install prawn-gmagick gem to add support" after enable the attribute allow-uri-read. Are there any plans to have this GEM installed in the provided image?

fhaefemeier avatar Aug 13 '20 16:08 fhaefemeier

Tried to embed image in PDF. Source is a URL (e.g. https://img.shields.io/badge/Status-Open-red). But get the warning "asciidoctor: WARNING: could not embed image: /tmp/image-20200813-1-1h5my3o; image file is an unrecognised format; install prawn-gmagick gem to add support" after enable the attribute allow-uri-read. Are there any plans to have this GEM installed in the provided image?

I see, after testing to load the missing packages it isn't an issue with the package. I get the same error.

fhaefemeier avatar Aug 13 '20 16:08 fhaefemeier

The warning message is unrelated to the problem in this case. You have specified a path to an SVG, but not indicated that it's an SVG. You can do so by appending .svg to the URL or adding the format=svg attribute to the macro.

mojavelinux avatar Aug 13 '20 19:08 mojavelinux

While writing tests, I've noticed that prawn-gmagick can mess up the palette of some PNGs. I'm not sure how prevalent this problem is, but we may need to provide an escape hatch (in Asciidoctor PDF) so it doesn't get automatically loaded if it is a real problem.

Asciidoctor PDF 2 will provide a script you can use to prevent prawn-gmagic from handling PNG images in this situation.

asciidoctor-pdf -r asciidoctor/pdf/nogmagick doc.adoc

It still leaves prawn-gmagick enabled for other image formats since they wouldn't otherwise be supported.

mojavelinux avatar Apr 28 '22 08:04 mojavelinux