grim icon indicating copy to clipboard operation
grim copied to clipboard

(WIP) Attempt at adding metadata to PNG output

Open ammgws opened this issue 6 years ago • 5 comments

An attempt at the PNG part for #6.

Brought over relevant code from cairo's cairo-png.c and added png_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

ammgws avatar Dec 16 '19 15:12 ammgws

Example libpng code, if that helps: https://github.com/swaywm/wlroots/blob/master/examples/screencopy.c#L171

emersion avatar Dec 20 '19 13:12 emersion

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:

  • Before this PR: 72 × 72 ppi
  • After after this PR: 11.811 × 11.811 pixels/mm

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.

ammgws avatar Dec 20 '19 14:12 ammgws

General style note: we don't align, we use tabs

emersion avatar Dec 20 '19 15:12 emersion

https://github.com/emersion/grim/pull/102 adds manual libpng calls.

emersion avatar Oct 08 '21 12:10 emersion

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.

ammgws avatar Oct 08 '21 14:10 ammgws