Closed dansouza closed 10 years ago
@dansouza, are you interested in submitting a patch for this? I will code review it and help out if so. A few other folks had expressed an interest in this, so it'd be a great feature.
I was halfway through an implementation myself. WebKit2 returns a Cairo surface. I can see a few different implementations for this: either we consume a cgo Cairo lib (e.g., go-cairo) and return a Go Cairo type; we return some kind of Go image type (image.RGBA?); or we do something similar to PhantomJS and take in a file path and render directly as a PNG or similar. Thoughts?
FWIW I like the RGBA solution, as Go already allows for easy image conversion using std libraries.
Awesome.
I would personally prefer one of the first 2 options (a Go Cairo type, or a Go image type), or a 3rd option of returning a typedef'd pointer that another lib could cast to get a C Cairo type (e.g., type RawCairoSurface *C.cairo_surface_t
) if they really wanted (but that doesn't require go-webkit2 to pull in go-cairo). But whichever one you find simplest is good with me.
@sqs, @bryansum alright guys, go ahead and implement this, since I can't promise a date to implement this due to my current work load. I agree that returning at a Go image type would be preferred. BTW, how does PhantomJS generate PDFs?
Slight update: Good and bad news. Good news is that Saucy snapshotting works! Bad news is that I spent an inordinate amount of time debugging the Raring version, which fails reliably. Should hopefully have a PR today.
@dansouza It looks like the current webkit2 snapshot implementation returns bitmap data. I imagine PhantomJS is hooking more deeply into the rendering layer, allowing for vector output.
Moving discussion to @bryansum's pull request https://github.com/sourcegraph/go-webkit2/pull/5
I think it would be awesome to implement a feature like https://github.com/ariya/phantomjs/wiki/Screen-Capture for screen capturing of elements.
Relevant discussion: http://www.reddit.com/r/golang/comments/1pig1q/gowebkit2_webkitgtk_v2_bindings_for_go_wheadless/cd3zkom