images-and-pixels
Installation
SKILL.md
Images and Pixels in Python
Trigger
Use this skill when the user:
- Creates an image with
bpy.data.images.newand fills it from code (test cards, masks, lookup textures, bake targets) - Reads or writes
Image.pixels, or mentionsforeach_get/foreach_set,float_buffer,is_float,channels - Hits
TypeErrorfrompixels.foreach_set/foreach_get(wrong length: RGB stride, or a buffer sized beforeImage.scale()) - Sees an image land upside down in the saved file, or pixels that changed after
Image.save() - Saves PNG or OpenEXR and loses alpha, gets low-alpha pixels clamped to white, or finds
save_renderwrote a PNG despiteimage.file_format = "OPEN_EXR"
High-level shape
import bpy
W, H = 512, 288
img = bpy.data.images.new("Card", W, H, alpha=True) # byte (8-bit) by default