Gimp 2.99 python3 plug-ins: writing a plugin to generate an image

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Gimp 2.99 python3 plug-ins: writing a plugin to generate an image

gmueller
Hello

is it possible writing a plug-in to generate an image without an opened
image? I found no examples. As a test I tried to open a file image only.
I've got the following message:

GIMP-Error: Procedure 'python-fu-openImageFile' has been called with an
invalid ID for argument 'image'. Most likely a plug-in is trying to work
on an image that doesn't exist any longer.

Here a code snippet:

def openImageFile(procedure, args, data):
     print("start openImageFile")
     return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS,
GLib.Error())


class OpenImageFile(Gimp.PlugIn):

     def do_query_procedures(self):
         return ["python-fu-openImageFile"]

     def do_create_procedure(self, name):
         data = None
         procedure = Gimp.ImageProcedure.new(
             self, name, Gimp.PDBProcType.PLUGIN, openImageFile, data
         )
         procedure.set_documentation(DESCR_SHORT, DESCR_LONG, name)
         procedure.set_attribution(AUTHOR, COPYRIGHT, DATE)
         procedure.set_menu_label(MENU_LABEL)
         procedure.add_menu_path(MENU_PATH)
         return procedure

Gimp.main(OpenImageFile.__gtype__, sys.argv)

I tried also an scheme script using gimp-file-load. It is using a GFile
argument now. In 2.10 I could use a filename. How to create a GFile in
scheme in 2.99?


Gottfried

_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list
Reply | Threaded
Open this post in threaded view
|

Re: Gimp 2.99 python3 plug-ins: writing a plugin to generate an image

Shlomi Fish
Hi Gottfried!

On Mon, 13 Jul 2020 10:29:32 +0200
Gottfried Müller <[hidden email]> wrote:

> Hello
>
> is it possible writing a plug-in to generate an image without an opened
> image? I found no examples. As a test I tried to open a file image only.
> I've got the following message:
>
> GIMP-Error: Procedure 'python-fu-openImageFile' has been called with an
> invalid ID for argument 'image'. Most likely a plug-in is trying to work
> on an image that doesn't exist any longer.
>
> Here a code snippet:
>
> def openImageFile(procedure, args, data):
>      print("start openImageFile")
>      return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS,
> GLib.Error())
>
>
> class OpenImageFile(Gimp.PlugIn):
>
>      def do_query_procedures(self):
>          return ["python-fu-openImageFile"]
>
>      def do_create_procedure(self, name):
>          data = None
>          procedure = Gimp.ImageProcedure.new(
>              self, name, Gimp.PDBProcType.PLUGIN, openImageFile, data
>          )
>          procedure.set_documentation(DESCR_SHORT, DESCR_LONG, name)
>          procedure.set_attribution(AUTHOR, COPYRIGHT, DATE)
>          procedure.set_menu_label(MENU_LABEL)
>          procedure.add_menu_path(MENU_PATH)
>          return procedure
>
> Gimp.main(OpenImageFile.__gtype__, sys.argv)
>

Perhaps this will help:

https://github.com/shlomif/gimp-lepton-support-for-dropbox-jpeg-compression/blob/87fde8b6252f6f6694b8ef5b97d5727925d74a7e/gimp-lepton/gimp-2.99/file-lepton.py

(short URL: https://is.gd/TlTlIF )

It is a gimp-python extension to open dropbox lepton .lep files:

https://github.com/dropbox/lepton

It took me some experimentation to write as well.

> I tried also an scheme script using gimp-file-load. It is using a GFile
> argument now. In 2.10 I could use a filename. How to create a GFile in
> scheme in 2.99?
>

Don't know about scheme.

>
> Gottfried
>
> _______________________________________________
> gimp-developer-list mailing list
> List address:    [hidden email]
> List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
> List archives:   https://mail.gnome.org/archives/gimp-developer-list



--

Shlomi Fish       https://www.shlomifish.org/
Why I Love Perl - https://shlom.in/joy-of-perl

Larry Wall *does* know all of Perl. However, he pretends to be wrong
or misinformed, so people will underestimate him.
    — https://www.shlomifish.org/humour/bits/facts/Larry-Wall/

Please reply to list if it's a mailing list post - https://shlom.in/reply .
_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list
Reply | Threaded
Open this post in threaded view
|

Re: Gimp 2.99 python3 plug-ins: writing a plugin to generate an image

Developers mailing list
In reply to this post by gmueller
> is it possible writing a plug-in to generate an image without an opened
image?

Rephrasing the question: can you write a plugin whose menu item is always
enabled, even without an open image?  That used to be possible, by passing
an empty string for the "image types" registration data.   But your code
does not call procedure.set_image_types(""); Even so,  in my experience
that does not work (at least for an image type procedure) in 2.99.   I
don't know the answer for 2.99, maybe there is another way, or it is a
"feature" that fell by the wayside when much of the plugin capability was
migrated inside Gimp from PyGimp.  Maybe just create a Gimp.Procedure
instead of a Gimp.ImageProcedure?

> How to create a GFile in  scheme in 2.99?

I opened issue https://gitlab.gnome.org/GNOME/gimp/-/issues/5402 reporting
this.  And I am working on a patch to Gimp.  You don't need to change your
plugin, Gimp code needs fixing.
_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list