Hello,
I'm working on Ubuntu 12.04, with Python 2.7 and Pyglet 1.1.4 (the ubuntu
repository version)
I'm trying to create a small python script to browse images in a folder and
transform it in another format. (I joined it to this mail).
I've modified the image_convert.py example, which I found in the pyglet's
examples folder.
The script works well with several image formats (JPG-> PNG, PNG->JPG...),
except if I want to transform pictures in DDS.
In this case, pyglet returns an exception :
--------------------------------------------------------------------
Traceback (most recent call last):
File "image_convert_travail.py", line 40, in <module>
convert(folder)
File "image_convert_travail.py", line 25, in convert
image.save(namefile+'.dds')
File "/usr/lib/pymodules/python2.7/pyglet/image/__init__.py", line 442,
in save
encoder.encode(self, file, filename)
File "/usr/lib/pymodules/python2.7/pyglet/image/codecs/pil.py", line 104,
in encode
raise ImageEncodeException(e)
pyglet.image.codecs.ImageEncodeException: 'DDS'
--------------------------------------------------------------------
I understand that pyglet doesn't find the DDS encoder.
Do you know where it is? (I didn't find it in pyglet files)
Does it exist in Linux package? (a friend of mine succeeded to encode a DDS
file with the original script, but he works under windows)
Or may be "image.save(namefile+'.dds')" is not sufficient... Should I
compress the texture before saving it in dds format?
Thanks for any reply.
All the best.
Vincent
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
'''Convert an image to another file format supported by pyglet.
Usage::
python image_convert.py <src-file> <dest-file>
'''
import os
import sys
import pyglet
def convert(folder):
for filitem in os.listdir(folder):
namefile=os.path.splitext(filitem)[0]
if '.dds' in filitem.lower():
texture = pyglet.image.load(str(os.path.dirname(folder))+'/'+filitem).get_texture()
texture.save(namefile+'.dds')
else:
image = pyglet.image.load(str(os.path.dirname(folder))+'/'+filitem)
image.save(namefile+'.dds')
if __name__ == '__main__':
if len(sys.argv) != 2:
print __doc__
sys.exit(1)
folder = sys.argv[1]
convert(folder)