nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
389 stars 19 forks source link

Image formats #58

Closed nx10 closed 3 years ago

nx10 commented 3 years ago

I have been thinking about how to implement server side rendering / export of image formats other than SVG. I came up with a number of different approaches:

  1. Implement custom renderers for each format directly in httpgd.
    • Pro: Fast and optimized output.
    • Cons: A lot of work. Increased complexity and package size.
  2. Modularize rendering. (C++ rendering API for httpgd "plugins")
    • Pro: Fast and optimized output. Small package size. Third party plugins.
    • Cons: Increased complexity of the dependency graph. Difficult to keep API stable and safe.
  3. Include conversion library (i.e. imagemagick) as a optional dependency to convert from SVG.
    • Pro: Very large number of formats supported without additional implementation cost.
    • Cons: Slower and unoptimized output.

I think 3. is the most realistic approach. This would also allow for renderers of specific formats to be implemented directly at a later date and use the library as a fallback if no custom renderer is available. A library candidate would be https://github.com/ropensci/magick . Which unfortunately does not seem to implement C++ bindings yet, if we decide on going that way we should ask there or if necessary implement a custom API with Magick++.

This issue is meant as an open discussion, I am open to all opinions and ideas.