Skip to content

Commit 06f6fec

Browse files
author
Sublime HQ Pty Ltd
committed
Merge pull request #5 from bwright/master
Capture Utility, Better Documentation and Configuration File
2 parents 7a87e13 + eb696c1 commit 06f6fec

File tree

5 files changed

+67
-4
lines changed

5 files changed

+67
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

README.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1-
Animation Encoder
2-
============
3-
1+
# Animation Encoder
2+
## Overview
43
anim_encoder creates small JavaScript+HTML animations from a series on PNG images.
4+
This is a modification of that original post, that adds some actual documentation
5+
cleans up the code base a bit and attempts to make it slightly more reliable. So that
6+
if anyone actually wants to use this is a project they can get up and running really
7+
quickly.
8+
9+
10+
Original details are at http://www.sublimetext.com/~jps/animated_gifs_the_hard_way.html
11+
12+
## Getting Started (Compiling the Example)
13+
```
14+
sudo apt-get install pngcrush python-opencv python-numpy python-scipy
15+
python anim_encoder.py example
16+
firefox example.html
17+
```
18+
19+
20+
## Capturing your own images
21+
Images will be saved to capture, you simply need to run capture.py and then go about your task.
22+
Note you can just delete frames you don't want as you initially set up, should save you some
23+
time. Then to run the program just go
24+
25+
```
26+
python capture.py
27+
```
528

6-
Details are at http://www.sublimetext.com/~jps/animated_gifs_the_hard_way.html
29+
If you need to change any settings it should be pretty simple just jump over to config.py
30+
and edit the configuration options.

capture.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# Benjamin James Wright <[email protected]>
3+
# This is a simple capture program that will capture a section of
4+
# the screen on a decided interval and then output the images
5+
# with their corresponding timestamps. (Borrowed from stackoverflow).
6+
# This will continue to capture for the seconds specified by argv[1]
7+
8+
import gtk.gdk
9+
import time
10+
import sys
11+
import config
12+
13+
14+
print "Starting Capture"
15+
print "================"
16+
17+
w = gtk.gdk.get_default_root_window()
18+
sz = w.get_size()
19+
20+
for i in xrange(0, config.CAPTURE_NUM):
21+
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
22+
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
23+
if (pb != None):
24+
pb.save("capture/screenshot_"+ str(int(time.time())) +".png","png")
25+
print "Screenshot " + str(i) + " saved."
26+
else:
27+
print "Unable to get the screenshot."
28+
time.sleep(config.CAPTURE_DELAY)

capture/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png

config.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# Benjamin James Wright <[email protected]>
3+
# This configuration file provides really basic settings for the capture system.
4+
5+
6+
# This defines the number of shots to take
7+
CAPTURE_NUM = 20
8+
# This is the delay between screenshots (in seconds)
9+
CAPTURE_DELAY = 1

0 commit comments

Comments
 (0)