Debian Codegraph @

examples/graphics/image_convert.py

raw symbols SCIP
1 #!/usr/bin/env python
2 """Convert an image to another file format supported by pyglet.
3
4 Usage::
5 python image_convert.py <src-file> <dest-file>
6
7 """
8
9
10 import sys
11
12 import pyglet
13
14
15 def convert(src, dest):
16 if '.dds' in src.lower():
17 # Compressed textures need to be uploaded to the video card before
18 # they can be saved.
19 texture = pyglet.image.load(src).get_texture()
20 texture.save(dest)
21 else:
22 # Otherwise just save the loaded image in the new format.
23 image = pyglet.image.load(src)
24 image.save(dest)
25
26
27 if __name__ == '__main__':
28 if len(sys.argv) != 3:
29 print(__doc__)
30 sys.exit(1)
31
32 src = sys.argv[1]
33 dest = sys.argv[2]
34 convert(src, dest)