+static PyObject* image_getattr(tag_internals_t*self,char*a)
+{
+ image_internal_t*i = (image_internal_t*)self->data;
+ if(!strcmp(a, "image")) {
+ if(!i->rgba) {
+ image_parse(self);
+ }
+ PyObject* image = rgba_to_image(i->rgba, i->width, i->height);
+ return image;
+ }
+ return 0;
+}
+
+static PyObject* image_save(PyObject*self, PyObject*args)
+{
+ tag_internals_t*itag = tag_getinternals(self);
+ if(!image_parse(itag))
+ return PY_ERROR("Couldn't parse image");
+ image_internal_t*fi = (image_internal_t*)itag->data;
+
+ char*filename = 0;
+ if(!PyArg_ParseTuple(args, "s", &filename))
+ return NULL;
+
+ writePNG(filename, fi->rgba ,fi->width, fi->height);
+
+ return PY_NONE;
+}
+
+static PyMethodDef image_methods[] =
+{{"save", image_save, METH_VARARGS, "saves an image as PNG"},
+ {NULL, NULL, 0, NULL}
+};
+