grafana/grafana-image-renderer

Pixel comparing to dynamically reduce screenshot resolution

hsolberg opened this issue · 4 comments

What would you like to be added:
Use pixel comparing (color) when pointing to a dashboard for rendering, instead of having to hardcode the resolution (which also might have to change when a dashboard is updated). By checking the nearest color of pixels it might then be possible to cut out empty parts of the screenshot?

Use case example:
Alerts having dashboard_url that's parsed by a script that grabs the image of the dashboard and appends it to the alert.

Suggested usage when implemented:
Having an optional variabel to turn the dynamic resolution on. Something like &dynamic_height=true or just &dynamic_height combined with the variables we already have &kiosk&width=3000&height=3000.

Why is this needed:
To make it easier to maintain a larger set of dashboards that you might not know the resolution of at all times (when you want to show all graphs in the dashboard).

Hello! To take a screenshot of the full dashboard, you should use height=-1. This will automatically scroll through the dashboard and calculate the required height to see all of it. Does it fit your use case?

height=-1 solves the case of showing the whole dashboard, but you get a lot of empty space below the graphs. Here's an example using ?kiosk&height=-1&width=3000.
demo

The full URL for the dashboard would be something like this (with anonymized data):
https://your-grafana-instance.domain/render/d/uniqueid/dashboardname?orgId=1&kiosk&height=-1&width=3000

EDIT

It seems adding a value for width overwrites the height resizing. If I remove or set width to -1 as well then it works (using width=-1 instead of removing it gives a better result it seems).

Is it supposed to work even with width set to a value other than -1?

After some more digging I think it's happening if you go beyond the width in the resolution set in config.json under args: "args": ["--no-sandbox", "--disable-gpu", "--window-size=1920x1080"].

Adjusting the window-size to 3080x3000 and using height=-1&width=2000 gives the desired result, but if I push the width up to 3000 it's struggeling to adjust. Seems the magic limit for width is 2500 before the scaling struggles.

I'll close this issue since it's working now. The only strange issue is the hard limit of width that seems to be at 2500 even if you set the window-size to a higher number. I don't think we'll ever need that high of a resolution, but it's an anomaly that someone might bump into for their use case.