Re: [Gimp-developer] How to call gimp_export_image() from Python plugin



On 18 June 2014 07:43, Vladimir Rutsky <rutsky vladimir gmail com> wrote:
On Wed, Jun 18, 2014 at 7:32 AM, Joao S. O. Bueno <gwidion gmail com> 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 <rutsky vladimir gmail com> 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]