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):
This is on OS-X with Blender 2.64. Am I not supposed to use the Image.pixels array like this? I saw somewhere that it would be faster to convert it to a list first (with list(img.pixes)), but then the conversion seems to take equally long...