Capturing PNGs of bruce slides?

1 view
Skip to first unread message

Ned Batchelder

unread,
Jan 9, 2009, 8:37:37 AM1/9/09
to bruce...@googlegroups.com
I'm preparing a Pycon talk, and am using Bruce (love it!), and would
like to get a set of PNG images of the slides. I'm trying to work out
how to get Bruce to produce a PNG for each slide. I've done a little
exploring to identify possible avenues, but don't know enough to know
the likely best candidate. Here's what I've got so far:

1) Get pyglet to render to an image instead of a screen. This seems
like the nicest approach, but I don't know if pyglet offers the
possibility of rendering to a PNG instead of an actual screen.

2) Display the slides with Bruce to the screen, and screen-grab to get
the image. I've looked into writing a plugin that simply uses PIL to
grab the screen. It would be added as the last element of each page, so
that when it is placed, it takes the grab. I can modify the slides to
add the plugin, and drive bruce to show each slide one at a time, and I
think I can even use win32 to find the location of the window to drive
PIL to get the right bits (whew!), but maybe there's a short-cut here?

3) Maybe there's another possibility?

I'm willing to hack almost any layer of the bruce stack to get the best
solution, but I'm a n00b at this code base, so don't know where the
grain of the wood lies.

--Ned.

--
Ned Batchelder, http://nedbatchelder.com


Drew Smathers

unread,
Jan 9, 2009, 10:13:16 AM1/9/09
to bruce...@googlegroups.com
On Fri, Jan 9, 2009 at 8:37 AM, Ned Batchelder <n...@nedbatchelder.com> wrote:
>
> I'm preparing a Pycon talk, and am using Bruce (love it!), and would
> like to get a set of PNG images of the slides. I'm trying to work out
> how to get Bruce to produce a PNG for each slide. I've done a little
> exploring to identify possible avenues, but don't know enough to know
> the likely best candidate. Here's what I've got so far:
>
> 1) Get pyglet to render to an image instead of a screen. This seems
> like the nicest approach, but I don't know if pyglet offers the
> possibility of rendering to a PNG instead of an actual screen.
>

With pyglet, dumping the screen looks something like this:

pyglet.image.get_buffer_manager().get_color_buffer().save('slide.png')

That will probably give you better quality than the latter approach,
although the simplest way to implement this is likely part of what
you've described in 2) - write some kind of plugin to drive bruce one
slide at a time and call the above. Since I'm not a bruce developer,
take this advice with a grain of salt.

Richard Jones

unread,
Jan 9, 2009, 4:32:09 PM1/9/09
to bruce...@googlegroups.com
On Sat, 10 Jan 2009, Ned Batchelder wrote:
> I'm preparing a Pycon talk, and am using Bruce (love it!), and would
> like to get a set of PNG images of the slides.

Hit control-S when you want a screenshot and a file screenshot-<random
number>.png will be written.

I'll add this to the README.txt :)


Richard

Ned Batchelder

unread,
Jan 10, 2009, 8:54:16 AM1/10/09
to bruce...@googlegroups.com
Thanks, I didn't know about Ctrl-S, but I'm looking for an automated way to get the pngs, something I could invoke from a Makefile, for instance.

Drew's line
   pyglet.image.get_buffer_manager().get_color_buffer().save('slide.png')

looks really good, but when I try putting it in a plug-in, I get a number of blank PNGs, so it's clear that the place() method in a plugin is not the right point in the pipeline to capture the look of the slide.

I have something very close, though.  I added an event called "on_page_changing" that is fired before navigating away from the page.  A handler for that event can use the get_color_buffer().save() line and capture nice PNGs.  It works great, except I don't know where to handle the last slide.  The Presentation.on_close() method doesn't get invoked when ending the presentation.  I tried adding an Presentation.on_pop() method, but the Director.on_pop() method is invoked instead.

Also, I still have to manually navigate through the slides to visit each one to get the images.  Maybe it's too much to expect an interactive display app like bruce to twist into a batch app like I'm imagining?

I've attached a diff showing what I've got so far...

--Ned.
http://nedbatchelder.com
screenshot.diff
Reply all
Reply to author
Forward
0 new messages