Sign up now! · Forgot password?
RSS/Atom feed Twitter

How to call gimp_export_image() from Python plugin

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

21 of 21 messages available
Toggle history

Please log in to manage your subscriptions.

How to call gimp_export_image() from Python plugin Vladimir Rutsky 17 Jun 22:43
  How to call gimp_export_image() from Python plugin Joao S. O. Bueno 18 Jun 03:32
   How to call gimp_export_image() from Python plugin Vladimir Rutsky 18 Jun 10:43
    How to call gimp_export_image() from Python plugin Joao S. O. Bueno 18 Jun 11:19
     How to call gimp_export_image() from Python plugin Vladimir Rutsky 18 Jun 12:27
      How to call gimp_export_image() from Pythonplugin Ed . 18 Jun 17:21
       How to call gimp_export_image() from Pythonplugin Joao S. O. Bueno 18 Jun 17:52
        How to call gimp_export_image() from Pythonplugin Ed . 18 Jun 18:57
        How to call gimp_export_image() from Pythonplugin Vladimir Rutsky 19 Jun 17:24
         How to call gimp_export_image() from Pythonplugin Ed . 19 Jun 18:09
          How to call gimp_export_image() from Pythonplugin Joao S. O. Bueno 19 Jun 18:33
           How to call gimp_export_image() from Pythonplugin Vladimir Rutsky 19 Jun 23:04
          How to call gimp_export_image() from Pythonplugin Vladimir Rutsky 19 Jun 22:52
           How to call gimp_export_image() from Pythonplugin Ed . 19 Jun 23:38
            How to call gimp_export_image() from Pythonplugin Joao S. O. Bueno 20 Jun 00:42
             How to call gimp_export_image() from Pythonplugin Vladimir Rutsky 20 Jun 22:13
              How to call gimp_export_image() from Pythonplugin Joao S. O. Bueno 20 Jun 22:59
               How to call gimp_export_image() from Pythonplugin Michael Schumacher 21 Jun 13:41
               How to call gimp_export_image() from Pythonplugin Ed . 21 Jun 21:02
                How to call gimp_export_image() from Pythonplugin Joao S. O. Bueno 22 Jun 14:43
                 How to call gimp_export_image() from Pythonplugin Ed . 23 Jun 06:41
Vladimir Rutsky
2014-06-17 22:43:55 UTC (almost 7 years ago)

How to call gimp_export_image() from Python plugin

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and docs (http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible via PDB either.

If it's not available, can you advice proper alternative? Should I report missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

Joao S. O. Bueno
2014-06-18 03:32:53 UTC (almost 7 years ago)

How to call gimp_export_image() from Python plugin

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js -> wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and docs (http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible via PDB either.

If it's not available, can you advice proper alternative? Should I report missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Vladimir Rutsky
2014-06-18 10:43:08 UTC (almost 7 years ago)

How to call gimp_export_image() from Python plugin

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and docs (http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible via PDB either.

If it's not available, can you advice proper alternative? Should I report missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

Joao S. O. Bueno
2014-06-18 11:19:11 UTC (almost 7 years ago)

How to call gimp_export_image() from Python plugin

On 18 June 2014 07:43, Vladimir Rutsky wrote:

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

so, just do the needed conversions through further PDB calls. as you can see, gimp_export_image is not available to plug-ins as of gimp 2.8 series.
(yes, it should be, and yes you can open a bug report requesting that so that we don't forget about it,
but this is an API change, so it will just be there for GIMP 2.10 anyway).

js ->

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and docs (http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible via PDB either.

If it's not available, can you advice proper alternative? Should I report missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

Vladimir Rutsky
2014-06-18 12:27:15 UTC (almost 7 years ago)

How to call gimp_export_image() from Python plugin

On Wed, Jun 18, 2014 at 3:19 PM, Joao S. O. Bueno wrote:

On 18 June 2014 07:43, Vladimir Rutsky wrote:

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

so, just do the needed conversions through further PDB calls. as you can see, gimp_export_image is not available to plug-ins as of gimp 2.8 series.
(yes, it should be, and yes you can open a bug report requesting that so that we don't forget about it,
but this is an API change, so it will just be there for GIMP 2.10 anyway).

Ok, thank you for clarification. I filed bug: https://bugzilla.gnome.org/show_bug.cgi?id=731843

Why it can be released sooner? I'm not familiar with GIMP development process, but I think exporting additional function doesn't break backward compatibility of API.
If I'll submit patches for this issue, when I can expect to see it in some official release of GIMP (in case patches will be accepted)?

-- Vladimir Rutsky

js
->

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and docs (http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible via PDB either.

If it's not available, can you advice proper alternative? Should I report missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

Ed .
2014-06-18 17:21:50 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

Just to clarify, JS - you say "gimp_export_image is not available to plug-ins as of gimp 2.8 series" - I take it you mean to Python plug-ins? Because it works fine in Gimp-Perl plug-ins.

I'd claim that the lack of gimp_export_image in pygimp is a bug, not a feature to be added, so it should be possible to add in 2.8. Vladimir, it ought to be as simple as adding to pygimp gimpexport, in the same way as there is gimpui. See
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html

Ed J Gimp-Perl guy

-----Original Message----- From: Vladimir Rutsky
Sent: Wednesday, June 18, 2014 1:27 PM To: gwidion@gmail.com
Cc: gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 3:19 PM, Joao S. O. Bueno wrote:

On 18 June 2014 07:43, Vladimir Rutsky wrote:

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

so, just do the needed conversions through further PDB calls. as you can see, gimp_export_image is not available to plug-ins as of gimp 2.8 series.
(yes, it should be, and yes you can open a bug report requesting that so that we don't forget about it,
but this is an API change, so it will just be there for GIMP 2.10 anyway).

Ok, thank you for clarification. I filed bug: https://bugzilla.gnome.org/show_bug.cgi?id=731843

Why it can be released sooner? I'm not familiar with GIMP development process, but I think exporting additional function doesn't break backward compatibility of API.
If I'll submit patches for this issue, when I can expect to see it in some official release of GIMP (in case patches will be accepted)?

-- Vladimir Rutsky

js
->

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and
docs
(http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer
image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible
via PDB either.

If it's not available, can you advice proper alternative? Should I report
missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership:
https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

Joao S. O. Bueno
2014-06-18 17:52:20 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

On 18 June 2014 14:21, Ed . wrote:

Just to clarify, JS - you say "gimp_export_image is not available to plug-ins as of gimp 2.8 series" - I take it you mean to Python plug-ins? Because it works fine in Gimp-Perl plug-ins.

I'd claim that the lack of gimp_export_image in pygimp is a bug, not a feature to be added, so it should be possible to add in 2.8. Vladimir, it ought to be as simple as adding to pygimp gimpexport, in the same way as there is gimpui. See
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html

Ed J Gimp-Perl guy

-----Original Message----- From: Vladimir Rutsky Sent: Wednesday, June 18, 2014 1:27 PM To: gwidion@gmail.com
Cc: gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 3:19 PM, Joao S. O. Bueno wrote:

On 18 June 2014 07:43, Vladimir Rutsky wrote:

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

so, just do the needed conversions through further PDB calls. as you can see, gimp_export_image is not available to plug-ins as of gimp 2.8 series.
(yes, it should be, and yes you can open a bug report requesting that so that we don't forget about it,
but this is an API change, so it will just be there for GIMP 2.10 anyway).

Ok, thank you for clarification. I filed bug: https://bugzilla.gnome.org/show_bug.cgi?id=731843

Why it can be released sooner? I'm not familiar with GIMP development process, but I think exporting additional function doesn't break backward compatibility of API.
If I'll submit patches for this issue, when I can expect to see it in some official release of GIMP (in case patches will be accepted)?

-- Vladimir Rutsky

js
->

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and
docs
(http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer
image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible
via PDB either.

If it's not available, can you advice proper alternative? Should I report
missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership:
https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Ed .
2014-06-18 18:57:38 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

Bottom line - switch to Gimp-Perl!

;-)

Ed J

-----Original Message----- From: Joao S. O. Bueno
Sent: Wednesday, June 18, 2014 6:52 PM To: Ed .
Cc: Vladimir Rutsky ; gimp-developer Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Vladimir Rutsky
2014-06-19 17:24:40 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 9:52 PM, Joao S. O. Bueno wrote:

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Joao, Ed,

so gimp_export_image() should be exported to Python though PDB (to all plugins) or by writing custom export code as done for some functions to export it only to Python?

-- Vladimir Rutsky

On 18 June 2014 14:21, Ed . wrote:

Just to clarify, JS - you say "gimp_export_image is not available to plug-ins as of gimp 2.8 series" - I take it you mean to Python plug-ins? Because it works fine in Gimp-Perl plug-ins.

I'd claim that the lack of gimp_export_image in pygimp is a bug, not a feature to be added, so it should be possible to add in 2.8. Vladimir, it ought to be as simple as adding to pygimp gimpexport, in the same way as there is gimpui. See
http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html

Ed J Gimp-Perl guy

-----Original Message----- From: Vladimir Rutsky Sent: Wednesday, June 18, 2014 1:27 PM To: gwidion@gmail.com
Cc: gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 3:19 PM, Joao S. O. Bueno wrote:

On 18 June 2014 07:43, Vladimir Rutsky wrote:

On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno wrote:

From Python, in GIMP 2.8, you have to make calls to whatever is available via the PDB, but
for some calls that have been shortened as methods of Image, Layer and other objects (but internally,
most things happen through the PDB anyway).

So, you have to call either "pdb.gimp_file_save" and specify the file format via the file-name extension,
or call "pdb.file_bmp_save". For both cases you have to passin a drawable to be saved, meaning that if you want to save an existingimage, you hvae to preceed these calls with the equivalent of these two lines:

saving_image = pdb.gimp_image_duplicate(img) saving_drawable = pdb.gimp_image_merge_visible_layers(saving_image)

then you have a drawable to save, with all the visible image contents, but without messing
with the image the user sees. After saving, call "pdb.gimp_image_delete(saving_image)" - to recover the resources used by the temporary image,

js ->

Thank for your reply, but this doesn't solves my problem.

merge_visible_layers() doesn't behave as gimp_export_image(): it only merges image layers to single layer. I need not only to merge them, but also to convert to proper image format suitable for me (e.g. convert to RGB from GRAY or RGBA) and probably some other convertions.

so, just do the needed conversions through further PDB calls. as you can see, gimp_export_image is not available to plug-ins as of gimp 2.8 series.
(yes, it should be, and yes you can open a bug report requesting that so that we don't forget about it,
but this is an API change, so it will just be there for GIMP 2.10 anyway).

Ok, thank you for clarification. I filed bug: https://bugzilla.gnome.org/show_bug.cgi?id=731843

Why it can be released sooner? I'm not familiar with GIMP development process, but I think exporting additional function doesn't break backward compatibility of API.
If I'll submit patches for this issue, when I can expect to see it in some official release of GIMP (in case patches will be accepted)?

-- Vladimir Rutsky

js
->

And gimp_export_image() designed specifically for my task.

According to it's sources (https://git.gnome.org/browse/gimp/tree/libgimp/gimpexport.c) there are quite a lot of steps and not so trivial logic that should be done to obtain result image, and I don't want to reimplement this functionality, I want to call gimp_export_image().

On 17 June 2014 19:43, Vladimir Rutsky wrote:

Hello!

I'm trying to write export plugin for custom image format in Python.

Looking at plugins implemented in C, e.g. gimp/plug-ins/file-bmp/bmp.c, and
docs
(http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpexport.html) I see, that best and recommended way to convert user image to single layer
image with proper capabilities is by using gimp_export_image() function.

How gimp_export_image() can be called from Python?

I can't find it exported Python modules and looks like it's not accessible
via PDB either.

If it's not available, can you advice proper alternative? Should I report
missing gimp_export_image() function in bug tracker?

Thanks in advance,

Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership:
https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

--
Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Ed .
2014-06-19 18:09:47 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

-----Original Message----- From: Vladimir Rutsky
Sent: Thursday, June 19, 2014 6:24 PM To: João Sebastião de Oliveira Bueno Cc: Ed . ; gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 9:52 PM, Joao S. O. Bueno wrote:

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Joao, Ed,

so gimp_export_image() should be exported to Python though PDB (to all plugins) or by writing custom export code as done for some functions to export it only to Python?

-- Vladimir Rutsky

Joao S. O. Bueno
2014-06-19 18:33:22 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

This is a missing feature in the 2.8 release. New features are usually not added in stable release cycle, which is the case of gimp 2.8 - and gimp-python is bound to it.

If it was something without which one would die - but the functionality can be obtained by 5 lines of code, as already answered in the first e-mail.

I will deal shortly with the other bug reported here - regarding the "parent" atribute of layers, which
is being retrieved as Layer, not LayerGroup. I might add the "export" method to GIMP Image objects - but that is a new feature , I am not sure if it should be backported to 2.8 .

On 19 June 2014 15:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 6:24 PM To: João Sebastião de Oliveira Bueno Cc: Ed . ; gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 9:52 PM, Joao S. O. Bueno wrote:

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Joao, Ed,

so gimp_export_image() should be exported to Python though PDB (to all plugins) or by writing custom export code as done for some functions to export it only to Python?

-- Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Vladimir Rutsky
2014-06-19 22:52:23 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

Which functions in GIMP goes to PDB, and which stays only in libgimp?

As I understand, libgimp should contain _all_ functionality, that may be needed for external C plugins. So it's "low-level" library.

PDB functions are designed to be called from scripts for automation and easer writing custom plugins in Scheme/Python/Perl scripts. So there mostly should be "high-level" functions, since there is no point in calling "low-level" operations, like set_pixel(), due to performance overhead of PDB.

gimp_export_image() is "high-level" function: it does several operations on image as whole and optionally asks user for some input. If gimp_export_image() would be available though PDB, it could be called from any "fu"-script, that can call PDB functions, and there would be no need to export it specifically in Python, Perl, Ruby, C#...

Correct me if I'm wrong, since I'm new to PDB and GIMP development.

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

Best way to use C functions from Python is to write wrapper module in C that will export methods as Python functions/classes (just as GIMP-Python does).
Also you can load shared object and call C-function directly using libffi library (presented as ctypes module in Python), but this error-prone and really hackish way.

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 6:24 PM To: João Sebastião de Oliveira Bueno Cc: Ed . ; gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 9:52 PM, Joao S. O. Bueno wrote:

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Joao, Ed,

so gimp_export_image() should be exported to Python though PDB (to all plugins) or by writing custom export code as done for some functions to export it only to Python?

-- Vladimir Rutsky

Vladimir Rutsky
2014-06-19 23:04:00 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:33, Joao S. O. Bueno wrote:

This is a missing feature in the 2.8 release. New features are usually not added in stable release cycle, which is the case of gimp 2.8 - and gimp-python is bound to it.

If it was something without which one would die - but the functionality can be obtained by 5 lines of code, as already answered in the first e-mail.

I will deal shortly with the other bug reported here - regarding the "parent" atribute of layers, which
is being retrieved as Layer, not LayerGroup. I might add the "export" method to GIMP Image objects - but that is a new feature , I am not sure if it should be backported to 2.8 .

I think this is a bug, that this function is not exported, but I agree with João about statement, that this function can be emulated so it's not worth risking stability of 2.8 release by exporting it.

-- Vladimir Rutsky

On 19 June 2014 15:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 6:24 PM To: João Sebastião de Oliveira Bueno Cc: Ed . ; gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On Wed, Jun 18, 2014 at 9:52 PM, Joao S. O. Bueno wrote:

IS it available throught the PDB? Most GIMP - Python functions are done via PDB, except pixel-region manipulation stuff.
If it is not in the PDB, it is not availabl in GIMP 2.8 - the current GIMP Python structure has to
special cases a lot of things to work aside from the PDB, and doing so is not minor stuff
done inside a release cycle.

Making the 3-4 above calls are straightforward - I see no reason to violate the principle of no new features inside a release to add this. In GIMP 2.10, the export feature will also have to deal with precision management, and besides this export function, a class of PDB calls dealing with precision needs
to be added as well.

Joao, Ed,

so gimp_export_image() should be exported to Python though PDB (to all plugins) or by writing custom export code as done for some functions to export it only to Python?

-- Vladimir Rutsky

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Ed .
2014-06-19 23:38:54 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

My understanding is that libgimp is for C plugins. Many libgimp functions are in fact calls to PDB functions - see libgimp/gimppainttools_pdb.c for example. The distinction between "high" and "low" level is not the one used to determine what is in the PDB and what is not - despite what you say, there are gimp-drawable-set-pixel and gimp-drawable-get-pixel procs in the PDB.

It seems you are knowledgeable in writing interface code for Python. Why not add gimp_export_image to the available python functions?

-----Original Message----- From: Vladimir Rutsky
Sent: Thursday, June 19, 2014 11:52 PM To: Ed .
Cc: gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

Which functions in GIMP goes to PDB, and which stays only in libgimp?

As I understand, libgimp should contain _all_ functionality, that may be needed for external C plugins. So it's "low-level" library.

PDB functions are designed to be called from scripts for automation and easer writing custom plugins in Scheme/Python/Perl scripts. So there mostly should be "high-level" functions, since there is no point in calling "low-level" operations, like set_pixel(), due to performance overhead of PDB.

gimp_export_image() is "high-level" function: it does several operations on image as whole and optionally asks user for some input. If gimp_export_image() would be available though PDB, it could be called from any "fu"-script, that can call PDB functions, and there would be no need to export it specifically in Python, Perl, Ruby, C#...

Correct me if I'm wrong, since I'm new to PDB and GIMP development.

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

Best way to use C functions from Python is to write wrapper module in C that will export methods as Python functions/classes (just as GIMP-Python does).
Also you can load shared object and call C-function directly using libffi library (presented as ctypes module in Python), but this error-prone and really hackish way.

Joao S. O. Bueno
2014-06-20 00:42:29 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 19 June 2014 20:38, Ed . wrote:

My understanding is that libgimp is for C plugins. Many libgimp functions are in fact calls to PDB functions - see libgimp/gimppainttools_pdb.c for example. The distinction between "high" and "low" level is not the one used to determine what is in the PDB and what is not - despite what you say, there are gimp-drawable-set-pixel and gimp-drawable-get-pixel procs in the PDB.

It seems you are knowledgeable in writing interface code for Python. Why not add gimp_export_image to the available python functions?

Because it is not there.

One problem with the current implementation of Pygimp is exactly that it uses C to wrap around calls do libgimp.
The problem with this approach is that one loses all the dynamic aspects from Python for these objects:
The GIMP Python objects,as exposed in pygimp are "native" objects - as such they can not be modified by pure Python code.

For writing Python plug-ins one does either use the objects ofered in Pygimp, with the functions enabled there in C code that requires a ton of boiler-plate for eachmethod made available, or use the Python PDB module, which allows one to call GIMP via the PDB.

So, if it is not clear yet, the "gimp_file_export" function just is _not_ there.
It can be made available by a C patch in pygimp - but that is adding functionality to a stable series.
Or it could be made available through the PDB - which would also make it work from script-fu,
and whatever other bindings happen to work. That is also adding new functionality.

The correct thing to do is to add it both ways - as an "export" method for image objects,
and as a PDB call - in the 2.9 branch.

Now, talking about new features, you where the one experiencing with GIMP and GIO - that, on the contrary of this simple call, is something that matters: I'd very much like to rewrite GIMP Python using GIO - (so this kind of stuff would be a non issue in the future: everything available in C is ready without needing explicit wrappers with boiler plate code) - how far did you get with the GIO stuff?

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 11:52 PM To: Ed .
Cc: gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

Which functions in GIMP goes to PDB, and which stays only in libgimp?

As I understand, libgimp should contain _all_ functionality, that may be needed for external C plugins. So it's "low-level" library.

PDB functions are designed to be called from scripts for automation and easer writing custom plugins in Scheme/Python/Perl scripts. So there mostly should be "high-level" functions, since there is no point in calling "low-level" operations, like set_pixel(), due to performance overhead of PDB.

gimp_export_image() is "high-level" function: it does several operations on image as whole and optionally asks user for some input. If gimp_export_image() would be available though PDB, it could be called from any "fu"-script, that can call PDB functions, and there would be no need to export it specifically in Python, Perl, Ruby, C#...

Correct me if I'm wrong, since I'm new to PDB and GIMP development.

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

Best way to use C functions from Python is to write wrapper module in C that will export methods as Python functions/classes (just as GIMP-Python does).
Also you can load shared object and call C-function directly using libffi library (presented as ctypes module in Python), but this error-prone and really hackish way.

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Vladimir Rutsky
2014-06-20 22:13:16 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 20.06.2014 04:42, Joao S. O. Bueno wrote:

On 19 June 2014 20:38, Ed . wrote:

My understanding is that libgimp is for C plugins. Many libgimp functions are in fact calls to PDB functions - see libgimp/gimppainttools_pdb.c for example. The distinction between "high" and "low" level is not the one used to determine what is in the PDB and what is not - despite what you say, there are gimp-drawable-set-pixel and gimp-drawable-get-pixel procs in the PDB.

It seems you are knowledgeable in writing interface code for Python. Why not add gimp_export_image to the available python functions?

Because it is not there.

One problem with the current implementation of Pygimp is exactly that it uses C to wrap around calls do libgimp.
The problem with this approach is that one loses all the dynamic aspects from Python for these objects:
The GIMP Python objects,as exposed in pygimp are "native" objects - as such they can not be modified by pure Python code.

For writing Python plug-ins one does either use the objects ofered in Pygimp, with the functions enabled there in C code that requires a ton of boiler-plate for eachmethod made available, or use the Python PDB module, which allows one to call GIMP via the PDB.

So, if it is not clear yet, the "gimp_file_export" function just is _not_ there.
It can be made available by a C patch in pygimp - but that is adding functionality to a stable series.
Or it could be made available through the PDB - which would also make it work from script-fu,
and whatever other bindings happen to work. That is also adding new functionality.

The correct thing to do is to add it both ways - as an "export" method for image objects,
and as a PDB call - in the 2.9 branch.

Now, talking about new features, you where the one experiencing with GIMP and GIO - that, on the contrary of this simple call, is something that matters: I'd very much like to rewrite GIMP Python using GIO - (so this kind of stuff would be a non issue in the future: everything available in C is ready without needing explicit wrappers with boiler plate code) - how far did you get with the GIO stuff?

What is GIO?
I heard about https://developer.gnome.org/gio/, but from it's description I don't get how it can be related to GIMP and it's plugins?

-- Vladimir Rutsky

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 11:52 PM To: Ed .
Cc: gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do gimpui stuff (also C functions), there is no conceptual reason why pygimp shouldn't also handle gimpexport (which is where gimp_export_image lives).

Which functions in GIMP goes to PDB, and which stays only in libgimp?

As I understand, libgimp should contain _all_ functionality, that may be needed for external C plugins. So it's "low-level" library.

PDB functions are designed to be called from scripts for automation and easer writing custom plugins in Scheme/Python/Perl scripts. So there mostly should be "high-level" functions, since there is no point in calling "low-level" operations, like set_pixel(), due to performance overhead of PDB.

gimp_export_image() is "high-level" function: it does several operations on image as whole and optionally asks user for some input. If gimp_export_image() would be available though PDB, it could be called from any "fu"-script, that can call PDB functions, and there would be no need to export it specifically in Python, Perl, Ruby, C#...

Correct me if I'm wrong, since I'm new to PDB and GIMP development.

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the GIMP UI - which pygimp already can initialise.

Best way to use C functions from Python is to write wrapper module in C that will export methods as Python functions/classes (just as GIMP-Python does).
Also you can load shared object and call C-function directly using libffi library (presented as ctypes module in Python), but this error-prone and really hackish way.

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Joao S. O. Bueno
2014-06-20 22:59:16 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

What is GIO?

It stands for "Gobject Introspection O"

It is a framework to,in a more or less automated form, expose C functions and gobject based classes to various languages - including Python.

The Python bindings for gtk+3.0 , ofr example, are GIO based - in this way, one does not have to re-especify every function or class one wants to expose to other languages in a manually written C (or other configuration) file.

Pygimp today has C modules which have to create Python objects that mimic GIMP objects, and all manipulations of these objects are wrapped by methods exposed
to Python which in turn call one of the libgimp functions.

With GIO, all libgimp functions could be called directly, and what we would need is an order of magnitude simpler implementation of the objects, directly in Python.

I am working on such a layer for GEGL, for example - http://github.com/jsbueno/python-gegl

js -> wrote:

On 20.06.2014 04:42, Joao S. O. Bueno wrote:

On 19 June 2014 20:38, Ed . wrote:

My understanding is that libgimp is for C plugins. Many libgimp functions are in fact calls to PDB functions - see libgimp/gimppainttools_pdb.c for example. The distinction between "high" and "low" level is not the one used
to determine what is in the PDB and what is not - despite what you say, there are gimp-drawable-set-pixel and gimp-drawable-get-pixel procs in the
PDB.

It seems you are knowledgeable in writing interface code for Python. Why not
add gimp_export_image to the available python functions?

Because it is not there.

One problem with the current implementation of Pygimp is exactly that it uses
C to wrap around calls do libgimp.
The problem with this approach is that one loses all the dynamic aspects from
Python for these objects:
The GIMP Python objects,as exposed in pygimp are "native" objects - as such
they can not be modified by pure Python code.

For writing Python plug-ins one does either use the objects ofered in Pygimp,
with the functions enabled there in C code that requires a ton of boiler-plate for eachmethod made available, or use the Python PDB module, which allows one to call GIMP via the PDB.

So, if it is not clear yet, the "gimp_file_export" function just is _not_ there.
It can be made available by a C patch in pygimp - but that is adding functionality to a stable series.
Or it could be made available through the PDB - which would also make it work from script-fu,
and whatever other bindings happen to work. That is also adding new functionality.

The correct thing to do is to add it both ways - as an "export" method for image objects,
and as a PDB call - in the 2.9 branch.

Now, talking about new features, you where the one experiencing with GIMP and GIO - that, on the contrary of this simple call, is something that matters: I'd very much like to rewrite GIMP Python using GIO - (so this kind of stuff would be a non issue in the future: everything available in C is ready without needing explicit wrappers with boiler plate code) - how far did you get with the GIO stuff?

What is GIO?
I heard about https://developer.gnome.org/gio/, but from it's description I don't get how it can be related to GIMP and it's plugins?

-- Vladimir Rutsky

-----Original Message----- From: Vladimir Rutsky Sent: Thursday, June 19, 2014 11:52 PM To: Ed .
Cc: gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On 19.06.2014 22:09, Ed . wrote:

It is not a PDB function, but a libgimp (C) function. Since pygimp can do
gimpui stuff (also C functions), there is no conceptual reason why pygimp
shouldn't also handle gimpexport (which is where gimp_export_image lives).

Which functions in GIMP goes to PDB, and which stays only in libgimp?

As I understand, libgimp should contain _all_ functionality, that may be needed for external C plugins. So it's "low-level" library.

PDB functions are designed to be called from scripts for automation and easer writing custom plugins in Scheme/Python/Perl scripts. So there mostly should be "high-level" functions, since there is no point in calling "low-level" operations, like set_pixel(), due to performance overhead of PDB.

gimp_export_image() is "high-level" function: it does several operations on image as whole and optionally asks user for some input. If gimp_export_image() would be available though PDB, it could be called from any "fu"-script, that can call PDB functions, and there would be no need to export it specifically in Python, Perl, Ruby, C#...

Correct me if I'm wrong, since I'm new to PDB and GIMP development.

I thought that in Python it was straightforward to access C functions? This is simply a function that returns an integer, albeit one that uses the
GIMP UI - which pygimp already can initialise.

Best way to use C functions from Python is to write wrapper module in C that will export methods as Python functions/classes (just as GIMP-Python does).
Also you can load shared object and call C-function directly using libffi library (presented as ctypes module in Python), but this error-prone and really hackish way.

_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership:
https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list

Michael Schumacher
2014-06-21 13:41:44 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 21.06.2014 00:59, Joao S. O. Bueno wrote:

What is GIO?

It stands for "Gobject Introspection O"

You're confusing GI[R] and GIO.

Regards,
Michael
GPG: 96A8 B38A 728A 577D 724D 60E5 F855 53EC B36D 4CDD
Ed .
2014-06-21 21:02:17 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

"GIO is a file access library and part of GLib." - http://wiki.gimp.org/index.php/Hacking:Porting_file_plugins_to_GEGL_and_GIO#Porting_to_GIO

GIR is "(GObject Introspection Repository)" - http://blogs.gnome.org/johan/2008/06/01/introduction-to-gobject-introspection/

GIR is something that GIMP will fully support when someone gets around to it - currently I've volunteered to be that guy.

Ed

-----Original Message----- From: Joao S. O. Bueno
Sent: Friday, June 20, 2014 11:59 PM To: Vladimir Rutsky
Cc: Ed . ; gimp-developer
Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

What is GIO?

It stands for "Gobject Introspection O"

It is a framework to,in a more or less automated form, expose C functions and
gobject based classes to various languages - including Python.

The Python bindings for gtk+3.0 , ofr example, are GIO based - in this way, one does not have to re-especify every function or class one wants to expose to other languages in a manually written C (or other configuration) file.

Pygimp today has C modules which have to create Python objects that mimic GIMP objects, and all manipulations of these objects are wrapped by methods exposed
to Python which in turn call one of the libgimp functions.

With GIO, all libgimp functions could be called directly, and what we would need is an order of magnitude simpler implementation of the objects, directly in Python.

I am working on such a layer for GEGL, for example - http://github.com/jsbueno/python-gegl

js

Joao S. O. Bueno
2014-06-22 14:43:28 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

On 21 June 2014 18:02, Ed . wrote:

"GIO is a file access library and part of GLib." - http://wiki.gimp.org/index.php/Hacking:Porting_file_plugins_to_GEGL_and_GIO#Porting_to_GIO

GIR is "(GObject Introspection Repository)" - http://blogs.gnome.org/johan/2008/06/01/introduction-to-gobject-introspection/

GIR is something that GIMP will fully support when someone gets around to it - currently I've volunteered to be that guy.

So - that is "GIR", not "GIO".

How far had you got?

Ed

-----Original Message----- From: Joao S. O. Bueno Sent: Friday, June 20, 2014 11:59 PM To: Vladimir Rutsky
Cc: Ed . ; gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

What is GIO?

It stands for "Gobject Introspection O"

It is a framework to,in a more or less automated form, expose C functions and
gobject based classes to various languages - including Python.

The Python bindings for gtk+3.0 , ofr example, are GIO based - in this way, one does not have to re-especify every function or class one wants to expose to other languages in a manually written C (or other configuration) file.

Pygimp today has C modules which have to create Python objects that mimic GIMP objects, and all manipulations of these objects are wrapped by methods exposed
to Python which in turn call one of the libgimp functions.

With GIO, all libgimp functions could be called directly, and what we would need is an order of magnitude simpler implementation of the objects, directly in Python.

I am working on such a layer for GEGL, for example - http://github.com/jsbueno/python-gegl

js

Ed .
2014-06-23 06:41:13 UTC (almost 7 years ago)

How to call gimp_export_image() from Pythonplugin

My progress so far as been to read a little about GIR.

-----Original Message----- From: Joao S. O. Bueno
Sent: Sunday, June 22, 2014 3:43 PM
To: Ed .
Cc: Vladimir Rutsky ; gimp-developer Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

On 21 June 2014 18:02, Ed . wrote:

"GIO is a file access library and part of GLib." - http://wiki.gimp.org/index.php/Hacking:Porting_file_plugins_to_GEGL_and_GIO#Porting_to_GIO

GIR is "(GObject Introspection Repository)" - http://blogs.gnome.org/johan/2008/06/01/introduction-to-gobject-introspection/

GIR is something that GIMP will fully support when someone gets around to it
- currently I've volunteered to be that guy.

So - that is "GIR", not "GIO".

How far had you got?

Ed

-----Original Message----- From: Joao S. O. Bueno Sent: Friday, June 20, 2014 11:59 PM To: Vladimir Rutsky
Cc: Ed . ; gimp-developer

Subject: Re: [Gimp-developer] How to call gimp_export_image() from Pythonplugin

What is GIO?

It stands for "Gobject Introspection O"

It is a framework to,in a more or less automated form, expose C functions and
gobject based classes to various languages - including Python.

The Python bindings for gtk+3.0 , ofr example, are GIO based - in this way, one does not have to re-especify every function or class one wants to expose to other languages in a manually written C (or other configuration) file.

Pygimp today has C modules which have to create Python objects that mimic GIMP objects, and all manipulations of these objects are wrapped by methods exposed
to Python which in turn call one of the libgimp functions.

With GIO, all libgimp functions could be called directly, and what we would need is an order of magnitude simpler implementation of the objects, directly in Python.

I am working on such a layer for GEGL, for example - http://github.com/jsbueno/python-gegl

js