geostyler / geostyler-legend

Small library to render map legends with OpenLayers and d3
BSD 2-Clause "Simplified" License
12 stars 9 forks source link

Add a PNG/JPEG output #390

Closed jahow closed 1 year ago

jahow commented 2 years ago

Feature Request

Following the possibility to render legends with inkmap (see https://github.com/camptocamp/inkmap/pull/49), I was wondering if it could be considered to add the possibility to render legends as PNG or JPEG as a complement to SVG. This would allow adding an image to a PDF document for example, or composing it with other images more easily.

The API could look something like that:

// options stay the same here
const renderer = new LegendRenderer({
    maxColumnWidth: 290,
    maxColumnHeight: 840,
    overflow: 'auto',
    styles: vectorLayerStyles,
    remoteLegends: remoteLegends,
  });
renderer.renderAsImage('png', 72); // returns an Image with a given DPI

Not sure exactly what it would mean in terms of effort for this library, let me know if it makes sense that I start experimenting on a branch!

jansule commented 2 years ago

This sounds like a good idea to me. But I would like to get @weskamm's opinion on that, too.

weskamm commented 2 years ago

Internally we still need to use SVG to join / layout multiple images, but it should be a great addition to have different final output formats. So feel free to start experiments :-)