-
Notifications
You must be signed in to change notification settings - Fork 37
(WIP) Attempt at adding metadata to PNG output #66
base: master
Are you sure you want to change the base?
Conversation
Example libpng code, if that helps: https://github.com/swaywm/wlroots/blob/master/examples/screencopy.c#L171 |
Cheers, I rewrote based on that and can at least get a file written to disk now, and have confirmed the scale metadata is there too. Resolution reported in "Image properties" in GIMP:
Now I just have to figure out how to get libpng to write to a buffer instead of to a file and this PR should be done. |
PNG_FILTER_TYPE_DEFAULT); | ||
|
||
#ifdef PNG_pHYs_SUPPORTED | ||
cairo_surface_get_fallback_resolution(sfc, &dpix, &dpiy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should get the px/mm value from the monitor's physical size: https://github.com/emersion/grim/blob/master/main.c#L113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Righto. For the case of a single output it would just be something like pixels_x/physical_width, but now I'm wondering how this should work for when the screenshot contains multiple outputs.
something like get_output_layout_extents / (sum of all physical sizes in the layout)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, except the screenshot region could partially span over multiple outputs. In general it may be even more complicated because different outputs could cover the same region.
I wonder if there's a good way to handle this.
General style note: we don't align, we use tabs |
#102 adds manual libpng calls. |
Nice, that solves the issue I was having tryng to get cairo to output to stdout (probably something silly on my part). That just leaves the discussion about what to do with screenshots spanning multiple monitors. |
An attempt at the PNG part for #6.
Brought over relevant code from cairo's
cairo-png.c
and addedpng_set_pHYs
call.At the moment it compiles but I've probably done something silly as only an empty file is generated. Opening WIP (Work in progress) PR now in case someone has time to look over the code in the meantime.
P.S.
What tool should I be using to format the files in order to honour the styling of this project? e.g. line length, braces, etc