gridgraphics icon indicating copy to clipboard operation
gridgraphics copied to clipboard

Use 'magick' package when installed

Open jeroen opened this issue 7 years ago • 8 comments

Currently one check failing because convert is not installed. Maybe try magick::image_convert which is available on most platforms. See here for an example.

jeroen avatar Jun 11 '17 09:06 jeroen

Thanks for the suggestion. If I am reading the 'magick' source correctly, this would still fail to build where ImageMagick is unavailable (i.e., 'magick' does not bundle ImageMagick), but would do so (far) more elegantly. Is that correct?

pmur002 avatar Jun 13 '17 01:06 pmur002

Not entirely. The magick package links to the libimagemagick C++ library, and can only be installed if the libimagemagick is available. This means that if the magick package is installed, it is guaranteed to work. You don't need to check for command line utilities at runtime.

Moreover, on windows and mac the CRAN binary packages ship with a statically linked libmagick++. The user doesn't need to install anything extra. Hence the R magick package will always work out of the box on Windows and OSX.

jeroen avatar Jun 13 '17 08:06 jeroen

Ah! Even better than I thought. I will look at using this - I also make use of ImageMagick's 'compare', but I see that there is also an interface for that in 'magick'. Thanks again!

pmur002 avatar Jun 13 '17 21:06 pmur002

Ok, small problem. When I convert, I want to specify -density, plus possibly +antialias. I can't see a way to do that with 'magick'

pmur002 avatar Jun 13 '17 22:06 pmur002

What exactly are you converting to what? There is a density parameter in image_read() to specify a density when rendering the input format into a bitmap object. I'll have to consult the documentation for antialiasing options...

If you're converting pdf to a bitmap type, also have a look at our pdftools::pdf_convert() which has very high quality bitmap rendering, and lets you specify a dpi as well (enables antialias by default)

jeroen avatar Jun 13 '17 22:06 jeroen

In some situations I need to do something like 'convert -density 100x100 +antialias test.pdf test.png' (but I also need to be able to adjust the density and to remove the +antialias)

pmur002 avatar Jun 13 '17 23:06 pmur002

Next problem :) When I do the image_compare() I want the visual diff file that 'compare' produces ...

pmur002 avatar Jun 14 '17 03:06 pmur002

I guess I could use image_composite() with appropriate operators to get the visual diff myself, but is there an easier way ?

pmur002 avatar Jun 14 '17 21:06 pmur002