PIL save "F" mode images?

I’m stuc can someone ‘unstuck’ me please?

While working on some terain generation I want to use an image to store hights. I would like to use Floats for precision, but I can’t how to make PIL (python image library) save “F” mode pictures. Does anyone know how to do this? (prefrably within Blender)

I’m usin Blender 2.41 and python 2.4

cheers Smitje

maybe you could use internal blender image capabilities? the new version should have complete floating point support for images.(will be probably in a month)

:stuck_out_tongue: jeeeeaaaa!
Imanaged to save a “F” mode file as tif (using python outside Blender)

But when I run the same script in Blender I get an ERROR :x

here is the script:


import Image

size = 65 
aapje = (1.0/3.0)
imgn = Image.new("F",(size, size),aapje)

imgn.save("D:/MCS/HexWrld/tryIm.tif")

and here is the error:


traceback ...
   File "myImage.py", line 7, in ?
   File "c:\Python\lib\site-packages\PILl\image.py", line 1305, in save
      save_handler(self, fp, filename)
   File "c:\Python\lib\site-packages\PILl\TiffImagePlugin.py", line 720, in _save
      ImageFile._save(im, fp, [
   File "c:\Python\lib\site-packages\PILl\ImageFile.py", line 489, in _save
      s = e.encode_to_file(fh, bufsize)
IOError: (0, 'Error')

does anyone know what this means, and if there is a sollution?
cheers Smitje

After some more experiments I’ve kind of decided to leave the floats for now because to manny functions in PIL are giving me a hard time over them.

now I am trying to decide weather to

  1. use an “L” mode immage and convert that to float when needed in Blender (e.g by multiplying with a Float) this has the advantage I can give it a sensible unit (meters)
    or
  2. use 2 layers of an “RGBA” mode image. That should give suficient detail, and leave the othes layers for some masking and other calculations (water) but would require a bit more calculation.

I am a bit in favor of the last option

any thoughts any one?
cheers
Smitje