You are here

"Layer to Image Size" via python script?

I'm in the process of creating a script that does the reverse of (that is, it takes a "tape" of frames in one layer and transforms it into an image the size of a single frame, with one layer per frame). The way I did this was to clone the original layer n-1 times (n frames for the sprite), then reposition each layer so that the desired frame is at image (0,0), then resize the image to the size of a single frame.

The problem is that the layers are all still the original size and I need them to be the size of the image. I can do this manually by using "Layer to Image Size" on each layer, but I'd prefer it to be done by the script.

Am I going about this the wrong way? Should I be moving the layer data to position the desired frame at layer (0,0)?


Okay, turns out I'm an idiot.

I looked into the documention for libgimp, and found that there's a call:

gimp_layer_resize_to_image_size ()

so I figured it couldn't hurt to see if the GIMP Python stuff implemented this as well. Turns out that:


works, and does exactly what I need. I iterate through all the layers and I have exactly the layered image I want.

Thanks for the pointer to the other script. It looks like there's lot of good stuff over there too.


Subscribe to Comments for ""Layer to Image Size" via python script?"