43
53
if (!PyArg_ParseTuple(args, "O!|i:add_layer", &PyGimpLayer_Type, &lay,
46
return PyInt_FromLong(gimp_image_add_layer(self->ID, lay->ID, pos));
57
if (!gimp_image_add_layer(self->ID, lay->ID, pos)) {
58
PyErr_Format(pygimp_error,
59
"could not add layer (ID %d) to image (ID %d)",
51
69
img_clean_all(PyGimpImage *self)
53
return PyInt_FromLong(gimp_image_clean_all(self->ID));
71
if (!gimp_image_clean_all(self->ID)) {
72
PyErr_Format(pygimp_error, "could not clean all on image (ID %d)",
58
82
img_disable_undo(PyGimpImage *self)
61
return PyInt_FromLong(gimp_image_undo_disable(self->ID));
84
return PyBool_FromLong(gimp_image_undo_disable(self->ID));
66
88
img_enable_undo(PyGimpImage *self)
68
return PyInt_FromLong(gimp_image_undo_enable(self->ID));
90
return PyBool_FromLong(gimp_image_undo_enable(self->ID));
73
94
img_flatten(PyGimpImage *self)
75
96
return pygimp_layer_new(gimp_image_flatten(self->ID));
80
100
img_lower_channel(PyGimpImage *self, PyObject *args)
82
102
PyGimpChannel *chn;
83
104
if (!PyArg_ParseTuple(args, "O!:lower_channel", &PyGimpChannel_Type, &chn))
85
return PyInt_FromLong(gimp_image_lower_channel(self->ID, chn->ID));
107
if (!gimp_image_lower_channel(self->ID, chn->ID)) {
108
PyErr_Format(pygimp_error,
109
"could not lower channel (ID %d) on image (ID %d)",
89
119
img_lower_layer(PyGimpImage *self, PyObject *args)
92
123
if (!PyArg_ParseTuple(args, "O!:lower_layer", &PyGimpLayer_Type, &lay))
94
return PyInt_FromLong(gimp_image_lower_layer(self->ID, lay->ID));
126
if (!gimp_image_lower_layer(self->ID, lay->ID)) {
127
PyErr_Format(pygimp_error,
128
"could not lower layer (ID %d) on image (ID %d)",
98
138
img_lower_layer_to_bottom(PyGimpImage *self, PyObject *args)
100
140
PyGimpLayer *lay;
101
142
if (!PyArg_ParseTuple(args, "O!:lower_layer_to_bottom",
102
143
&PyGimpLayer_Type, &lay))
104
return PyInt_FromLong(gimp_image_lower_layer_to_bottom(self->ID, lay->ID));
146
if (!gimp_image_lower_layer_to_bottom(self->ID, lay->ID)) {
147
PyErr_Format(pygimp_error,
148
"could not lower layer (ID %d) to bottom on image (ID %d)",
107
157
static PyObject *
163
227
if (!PyArg_ParseTuple(args, "O!:raise_channel", &PyGimpChannel_Type, &chn))
165
return PyInt_FromLong(gimp_image_raise_channel(self->ID, chn->ID));
230
if (!gimp_image_raise_channel(self->ID, chn->ID)) {
231
PyErr_Format(pygimp_error,
232
"could not raise channel (ID %d) on image (ID %d)",
168
241
static PyObject *
169
242
img_raise_layer(PyGimpImage *self, PyObject *args)
171
244
PyGimpLayer *lay;
172
246
if (!PyArg_ParseTuple(args, "O!:raise_layer", &PyGimpLayer_Type, &lay))
174
return PyInt_FromLong(gimp_image_raise_layer(self->ID, lay->ID));
249
if (!gimp_image_raise_layer(self->ID, lay->ID)) {
250
PyErr_Format(pygimp_error,
251
"could not raise layer (ID %d) on image (ID %d)",
177
260
static PyObject *
178
261
img_raise_layer_to_top(PyGimpImage *self, PyObject *args)
180
263
PyGimpLayer *lay;
181
265
if (!PyArg_ParseTuple(args, "O!:raise_layer_to_top",
182
266
&PyGimpLayer_Type, &lay))
184
return PyInt_FromLong(gimp_image_raise_layer_to_top(self->ID, lay->ID));
269
if (!gimp_image_raise_layer_to_top(self->ID, lay->ID)) {
270
PyErr_Format(pygimp_error,
271
"could not raise layer (ID %d) to top on image (ID %d)",
187
280
static PyObject *
188
281
img_remove_channel(PyGimpImage *self, PyObject *args)
190
283
PyGimpChannel *chn;
191
285
if (!PyArg_ParseTuple(args, "O!:remove_channel", &PyGimpChannel_Type, &chn))
193
return PyInt_FromLong(gimp_image_remove_channel(self->ID, chn->ID));
288
if (!gimp_image_remove_channel(self->ID, chn->ID)) {
289
PyErr_Format(pygimp_error,
290
"could not remove channel (ID %d) from image (ID %d)",
197
299
static PyObject *
198
300
img_remove_layer(PyGimpImage *self, PyObject *args)
200
302
PyGimpLayer *lay;
201
304
if (!PyArg_ParseTuple(args, "O!:remove_layer", &PyGimpLayer_Type, &lay))
203
return PyInt_FromLong(gimp_image_remove_layer(self->ID, lay->ID));
208
img_resize(PyGimpImage *self, PyObject *args)
213
if (!PyArg_ParseTuple(args, "iiii:resize", &new_w, &new_h,
216
return PyInt_FromLong(gimp_image_resize(self->ID, new_w, new_h,
221
img_scale(PyGimpImage *self, PyObject *args)
223
gint new_width, new_height;
225
if (!PyArg_ParseTuple(args, "ii:scale", &new_width, &new_height))
227
return PyInt_FromLong(gimp_image_scale(self->ID, new_width, new_height));
231
img_crop(PyGimpImage *self, PyObject *args)
235
if (!PyArg_ParseTuple(args, "iiii:crop", &new_w, &new_h,
238
return PyInt_FromLong(gimp_image_crop(self->ID, new_w, new_h,
307
if (!gimp_image_remove_layer(self->ID, lay->ID)) {
308
PyErr_Format(pygimp_error,
309
"could not remove layer (ID %d) from image (ID %d)",
319
img_resize(PyGimpImage *self, PyObject *args, PyObject *kwargs)
322
int offs_x = 0, offs_y = 0;
324
static char *kwlist[] = { "width", "height", "offset_x", "offset_y",
327
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:resize", kwlist,
328
&new_w, &new_h, &offs_x, &offs_y))
331
if (!gimp_image_resize(self->ID, new_w, new_h, offs_x, offs_y)) {
332
PyErr_Format(pygimp_error,
333
"could not resize image (ID %d) to %dx%d, offset %d, %d",
334
self->ID, new_w, new_h, offs_x, offs_y);
343
img_scale(PyGimpImage *self, PyObject *args, PyObject *kwargs)
345
int new_width, new_height;
347
static char *kwlist[] = { "width", "height", NULL };
349
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:scale", kwlist,
350
&new_width, &new_height))
353
if (!gimp_image_scale(self->ID, new_width, new_height)) {
354
PyErr_Format(pygimp_error, "could not scale image (ID %d) to %dx%d",
355
self->ID, new_width, new_height);
364
img_crop(PyGimpImage *self, PyObject *args, PyObject *kwargs)
367
int offs_x = 0, offs_y = 0;
369
static char *kwlist[] = { "width", "height", "offset_x", "offset_y",
372
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:crop", kwlist,
373
&new_w, &new_h, &offs_x, &offs_y))
376
if (!gimp_image_crop(self->ID, new_w, new_h, offs_x, offs_y)) {
377
PyErr_Format(pygimp_error,
378
"could not crop image (ID %d) to %dx%d, offset %d, %d",
379
self->ID, new_w, new_h, offs_x, offs_y);
242
387
static PyObject *
243
388
img_free_shadow(PyGimpImage *self)
245
return PyInt_FromLong(gimp_image_free_shadow(self->ID));
390
if (!gimp_image_free_shadow(self->ID)) {
391
PyErr_Format(pygimp_error, "could not free shadow on image (ID %d)",
248
400
static PyObject *
249
401
img_unset_active_channel(PyGimpImage *self)
251
return PyInt_FromLong(gimp_image_unset_active_channel(self->ID));
403
if (!gimp_image_unset_active_channel(self->ID)) {
404
PyErr_Format(pygimp_error,
405
"could not unset active channel on image (ID %d)",
254
414
static PyObject *
255
415
img_get_component_active(PyGimpImage *self, PyObject *args)
258
419
if (!PyArg_ParseTuple(args, "i:get_component_active", &comp))
260
return PyInt_FromLong(gimp_image_get_component_active(self->ID, comp));
422
return PyBool_FromLong(gimp_image_get_component_active(self->ID, comp));
277
439
img_set_component_active(PyGimpImage *self, PyObject *args)
280
443
if (!PyArg_ParseTuple(args, "ii:set_component_active", &comp, &a))
282
return PyInt_FromLong(gimp_image_set_component_active(self->ID, comp, a));
446
if (!gimp_image_set_component_active(self->ID, comp, a)) {
447
PyErr_Format(pygimp_error,
448
"could not set component (%d) %sactive on image (ID %d)",
449
comp, a ? "" : "in", self->ID);
286
457
static PyObject *
287
458
img_set_component_visible(PyGimpImage *self, PyObject *args)
290
462
if (!PyArg_ParseTuple(args, "ii:set_component_visible", &comp, &v))
292
return PyInt_FromLong(gimp_image_set_component_visible(self->ID, comp, v));
465
if (!gimp_image_set_component_visible(self->ID, comp, v)) {
466
PyErr_Format(pygimp_error,
467
"could not set component (%d) %svisible on image (ID %d)",
468
comp, v ? "" : "in", self->ID);
295
476
static PyObject *
296
477
img_parasite_find(PyGimpImage *self, PyObject *args)
299
481
if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
301
484
return pygimp_parasite_new(gimp_image_parasite_find(self->ID, name));
305
488
img_parasite_attach(PyGimpImage *self, PyObject *args)
307
490
PyGimpParasite *parasite;
308
492
if (!PyArg_ParseTuple(args, "O!:parasite_attach", &PyGimpParasite_Type,
311
return PyInt_FromLong(gimp_image_parasite_attach(self->ID,parasite->para));
496
if (!gimp_image_parasite_attach(self->ID, parasite->para)) {
497
PyErr_Format(pygimp_error,
498
"could not attach parasite '%s' to image (ID %d)",
499
parasite->para->name, self->ID);
314
507
static PyObject *
315
img_attach_new_parasite(PyGimpImage *self, PyObject *args)
508
img_attach_new_parasite(PyGimpImage *self, PyObject *args, PyObject *kwargs)
319
if (!PyArg_ParseTuple(args, "sis#:attach_new_parasite", &name, &flags,
322
gimp_image_attach_new_parasite(self->ID, name, flags, size, data);
514
static char *kwlist[] = { "name", "flags", "data", NULL };
516
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
517
"sis#:attach_new_parasite", kwlist,
518
&name, &flags, &data, &size))
521
if (!gimp_image_attach_new_parasite(self->ID, name, flags, size, data)) {
522
PyErr_Format(pygimp_error,
523
"could not attach new parasite '%s' to image (ID %d)",
323
528
Py_INCREF(Py_None);
482
741
{"raise_layer_to_top", (PyCFunction)img_raise_layer_to_top, METH_VARARGS},
483
742
{"remove_channel", (PyCFunction)img_remove_channel, METH_VARARGS},
484
743
{"remove_layer", (PyCFunction)img_remove_layer, METH_VARARGS},
485
{"resize", (PyCFunction)img_resize, METH_VARARGS},
744
{"resize", (PyCFunction)img_resize, METH_VARARGS | METH_KEYWORDS},
486
745
{"get_component_active", (PyCFunction)img_get_component_active, METH_VARARGS},
487
746
{"get_component_visible", (PyCFunction)img_get_component_visible, METH_VARARGS},
488
747
{"set_component_active", (PyCFunction)img_set_component_active, METH_VARARGS},
489
748
{"set_component_visible", (PyCFunction)img_set_component_visible, METH_VARARGS},
490
749
{"parasite_find", (PyCFunction)img_parasite_find, METH_VARARGS},
491
750
{"parasite_attach", (PyCFunction)img_parasite_attach, METH_VARARGS},
492
{"attach_new_parasite", (PyCFunction)img_attach_new_parasite,METH_VARARGS},
751
{"attach_new_parasite", (PyCFunction)img_attach_new_parasite, METH_VARARGS | METH_KEYWORDS},
493
752
{"parasite_detach", (PyCFunction)img_parasite_detach, METH_VARARGS},
494
753
{"parasite_list", (PyCFunction)img_parasite_list, METH_NOARGS},
495
754
{"get_layer_by_tattoo",(PyCFunction)img_get_layer_by_tattoo,METH_VARARGS},