I'm writing a small Python script using the PIL module to change the size of some textures used on a 3D Model in MultiGen Creator. I'm also using the openflight API so that's what the mg* functions are.
Here's the script
import PIL
from PIL import Image
db = mgGetCurrentDb()
ret,index,name = mgGetFirstTexture (db)
while (ret):
myAttr = mgReadImageAttributes (name)
existingattrs = mgGetAttList (myAttr,fltImgHeight,fltImgWidth)
print existingattrs[2]
print existingattrs[4]
if existingattrs[2] != 0 and existingattrs[4] != 0:
Height = existingattrs[2]/4
Width = existingattrs[4]/4
print name
print Width
print Height
imageFile = (name)
im1 = Image.open(imageFile)
im2 = im1.resize((Width,Height),PIL.Image.BILINEAR)
ImgOut = "C:\DB\PLW\out.jpg"
im2.save(ImgOut)
ret,index,name = mgGetNextTexture (db)
Anyway all seems to work but when I try and write the file I get the following error
E: Traceback (most recent call last):
E: File "<string>", line 24, in <module>
E: File "C:\Python25\lib\site-packages\PIL\Image.py", line 1439, in save
E: save_handler(self, fp, filename)
E: File "C:\Python25\Lib\site-packages\PIL\JpegImagePlugin.py", line 471, in _save
E: ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
E: File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 499, in _save
E: s = e.encode_to_file(fh, bufsize)
E: IOError: [Errno 0] Error