I'm using PIL to an addon I'm working on and at some point I need to open images using pillow. The usual way to do is
from PIL import Image
Image.open('whatever your image is')
But with images created within Blender, the only access is using
bpy.data.image['the image']
which causes error using Image.open
from PIL.
I get the following error when I type:
Image.open(bpy.data.image['test'])
Traceback (most recent call last):
File "C:\Users\myName\AppData\Roaming\Python\Python39\site-packages\PIL\Image.py", line 3096, in open
fp.seek(0)
AttributeError: 'Image' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Users\myName\AppData\Roaming\Python\Python39\site-packages\PIL\Image.py", line 3098, in open
fp = io.BytesIO(fp.read())
AttributeError: 'Image' object has no attribute 'read'
I found some idea using pixels and Image.fromarray
but nothing conclusive so far...
How do you load Blender's image like bpy.data.image['the image']
into PIL image?
bpy.types.Image
as if it were aPIL.Image
but those are not the same thing. bpy vs. PIL objects. $\endgroup$