Update to 0.3.0 (New upstream + new RPC calls)
[novacoin.git] / share / qt / make_spinner.py
1 #!/usr/bin/env python
2 # W.J. van der Laan, 2011
3 # Make spinning .mng animation from a .png
4 # Requires imagemagick 6.7+
5 from __future__ import division
6 from os import path
7 from PIL import Image
8 from subprocess import Popen
9
10 SRC='img/reload_scaled.png'
11 DST='../../src/qt/res/movies/update_spinner.mng'
12 TMPDIR='/tmp'
13 TMPNAME='tmp-%03i.png'
14 NUMFRAMES=35
15 FRAMERATE=10.0
16 CONVERT='convert'
17 CLOCKWISE=True
18 DSIZE=(16,16)
19
20 im_src = Image.open(SRC)
21
22 if CLOCKWISE:
23     im_src = im_src.transpose(Image.FLIP_LEFT_RIGHT)
24
25 def frame_to_filename(frame):
26     return path.join(TMPDIR, TMPNAME % frame)
27
28 frame_files = []
29 for frame in xrange(NUMFRAMES):
30     rotation = (frame + 0.5) / NUMFRAMES * 360.0
31     if CLOCKWISE:
32         rotation = -rotation
33     im_new = im_src.rotate(rotation, Image.BICUBIC)
34     im_new.thumbnail(DSIZE, Image.ANTIALIAS)
35     outfile = frame_to_filename(frame)
36     im_new.save(outfile, 'png')
37     frame_files.append(outfile)
38
39 p = Popen([CONVERT, "-delay", str(FRAMERATE), "-dispose", "2"] + frame_files + [DST])
40 p.communicate()
41
42
43