Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prawn-gmagick gem #121

Open
mojavelinux opened this issue Jan 24, 2020 · 7 comments
Open

Add prawn-gmagick gem #121

mojavelinux opened this issue Jan 24, 2020 · 7 comments
Projects

Comments

@mojavelinux
Copy link
Member

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

@bcouetil
Copy link

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

@mojavelinux
Copy link
Member Author

mojavelinux commented Jan 28, 2020 via email

@das-g
Copy link

das-g commented Apr 22, 2020

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.

@fhaefemeier
Copy link

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
Copy link

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.

@mojavelinux
Copy link
Member Author

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.

@dduportal dduportal added this to TODO in Tasks via automation Mar 2, 2021
@mojavelinux
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Tasks
  
TODO
Development

No branches or pull requests

5 participants