As part of a custom exporter, I'm trying to copy the pixels of a texture image to a file.
However, it seems that accessing the Image.pixel array is very slow. If I read every pixel of a 128x128 image and write it to a file, it takes around 10 seconds. For a 1024x1024 image, it seems to take forever (I didn't have the patience to wait and killed Blender).
What I'm doing is something like this (I'm new to Python):
Code: Select all
f = open("/tmp/pixels", "wb") img = bpy.images for i in range(0, img.size * img.size * 4): f.write(struct.pack("@f", img.pixels[i]))