Saving packed image

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
rogma
Posts: 0
Joined: Fri Apr 29, 2005 11:23 am

Saving packed image

Post by rogma »

Hi,

I have a model with packed image an I would like to save them to files through python. I searched the API and some forums but I did not find any clue.

Is it possible ?

rogma
Posts: 0
Joined: Fri Apr 29, 2005 11:23 am

Post by rogma »

If it is not possible to unpack an Image through python,could it be considered as a feature for future release ?

Perhaps it could be something like a save method in Image class

image = Blender.Image.Get("image")
image.save(/path/to/myimage/")

where save would take a directory path and the image be saved in taht directory as image_name.image_extension.
Regards

SKPjason
Posts: 1
Joined: Wed Apr 16, 2003 8:12 pm

Post by SKPjason »

I'm just curious what would be the advantage to doing this through python instead of just using the unpack feature to save the pic files?

rogma
Posts: 0
Joined: Fri Apr 29, 2005 11:23 am

Post by rogma »

first sorry for the late response

The usage of such a feature is to automate model export with batch feature

with blender batch feature one could transform a blender model containing its texture into whatever (for example a ogre mesh + textre file + materials)

Hope it is clear

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip »

{"unpack", ( PyCFunction ) Image_unpack, METH_VARARGS,
"(int) - Unpack image. Uses the values defined in Blender.UnpackModes."},


static PyObject *Blender_UnpackModesDict( void )
{
PyObject *UnpackModes = PyConstant_New( );
if( UnpackModes ) {
BPy_constant *d = ( BPy_constant * ) UnpackModes;
PyConstant_Insert( d, "EQUAL", PyInt_FromLong((long)PF_EQUAL) );
PyConstant_Insert( d, "DIFFERS",PyInt_FromLong((long)PF_DIFFERS) );
PyConstant_Insert( d, "NOFILE", PyInt_FromLong((long)PF_NOFILE) );
PyConstant_Insert( d, "WRITE_ORIGINAL", PyInt_FromLong((long)PF_WRITE_ORIGINAL) );
PyConstant_Insert( d, "WRITE_LOCAL", PyInt_FromLong((long)PF_WRITE_LOCAL) );
PyConstant_Insert( d, "USE_LOCAL", PyInt_FromLong((long)PF_USE_LOCAL) );
PyConstant_Insert( d, "USE_ORIGINAL", PyInt_FromLong((long)PF_USE_ORIGINAL) );
PyConstant_Insert( d, "KEEP", PyInt_FromLong((long)PF_KEEP) );
PyConstant_Insert( d, "NOOP", PyInt_FromLong((long)PF_NOOP) );
PyConstant_Insert( d, "ASK", PyInt_FromLong((long)PF_EQUAL) );
}
return UnpackModes;

LetterRip

rogma
Posts: 0
Joined: Fri Apr 29, 2005 11:23 am

Post by rogma »

thanks :D

Post Reply