Python Plug In file-heif-save - Printable Version

+- (
+-- Forum: GIMP (
+--- Forum: Extending the GIMP (
+---- Forum: Scripting questions (
+---- Thread: Python Plug In file-heif-save (/Thread-Python-Plug-In-file-heif-save)

Python Plug In file-heif-save - Julio85 - 09-06-2018

I´m trying to use that Python PlugIn and it doesn´t work, maybe I´m doing something wrong or introducing wrong parameters.
I need an example to make it work.

I´m using the last version GIMP 2.10.6
pdb.file_heif_save(image, drawable, uri, raw_uri, quality, lossless)

Thanks in advance.

RE: Python Plug In file-heif-save - rich2005 - 09-06-2018

AFAIK the plugin does not export, only open. I think there is a bug report about that. The progress report bottom of Gimp window show an export but no file is produced.

These 2 made with the heif linux encoder, lenna-100 is lossless lenna-50 is 50% quality setting

So an example of code might not be any use.

RE: Python Plug In file-heif-save - rich2005 - 09-06-2018

I am wrong, Gimp does indeed save a .heif file, any old problems are fixed. (although not in my linux flatpak)

So what you need is one of the clever guys to advise on the syntax.

run-mode INT32 The run mode { RUN-NONINTERACTIVE (1)}
image IMAGE Input image
drawable DRAWABLE Drawable to export
filename STRING The name ofthefile to export the image in
raw-filename STRING The name of the file to export the image in
quality INT32 Quality factor (range: 0-100. 0 = worst. 100 = best)
lossless INT32 Use lossless compression (0 = lossy 1 = lossless)

I thought I might get this working in BIMP but it comes unstuck with the filename parameters.

RE: Python Plug In file-heif-save - Julio85 - 09-06-2018

Yes! I need one of the clever guys for an example.

This is the error that appear in Python Console:

Traceback (most recent call last):

  File "<input>", line 1, in <module>
TypeError: wrong parameter type

Thanks for your answer!!

RE: Python Plug In file-heif-save - Ofnuts - 09-06-2018

You are lucky, what I get from that plugin is:

/app/lib/gimp/2.0/plug-ins/file-heif/file-heif: fatal error: Segmentation fault
Terminating plug-in: '/app/lib/gimp/2.0/plug-ins/file-heif/file-heif'

(whether I try to call it in a script or use File/Export in the UI)

Now, I can't even find a HEIC image to download to attempt to open it.

RE: Python Plug In file-heif-save - jmarcorb - 09-08-2018

I was trying to use this plugin from external command line but could not figure it out. Confused

Luckily I found

With this finally I understood how to call this plugin, this is, not directly but via another script. For me it worked creating and registering my own script that used file-heif-save, after that it was just a matter of executing from bash, as shown in the link.

Using the great scripts developed by David M. MacMillan (thanks for sharing under GNU GPL), like dmmConvertPNGtoJPG, I changed bits and pieces so that script used file-heif-save instead of file-jpeg-save. Later it was a matter of placing it in GIMP scripts folder, refreshing GIMP's script-fu scripts, and calling the registered script from bash shell.

(define (convertJPGtoHEIF infile outfile)
  (let* ((image (car (file-jpeg-load 1 infile infile)))
         (drawable (car (gimp-image-active-drawable image)))

        (file-heif-save 1 image drawable outfile outfile
             50 0 )
           ; 50 quality (int32 0 <= x <= 100)
           ;      0 use lossless compression (0 = lossy, 1 = lossless)


  "convertJPGtoHEIF"                             ; script name to register
  "<Toolbox>/Xtns/Script-Fu/conv/convertJPGtoHEIF" ; where it goes
  "Convert JPG to HEIF"                         ; script description
  "David M. MacMillan, modded by jmarcorb"          ; author
  "Copyright 2004 by David M. MacMillan; GNU GPL"  ; copyright
  "2018-09-08"                                     ; date
  ""                                               ; type of image
  SF-FILENAME "Infile" "infile.png"                ; default parameters
  SF-FILENAME "Outfile" "outfile.png"
Register in GIMP and then execute from bash:

gimp -c -i -d -b "(convertJPGtoHEIF \"image2.jpg\" \"image2.heif\")" "(gimp-quit 0)"

Hope it helps Big Grin .

RE: Python Plug In file-heif-save - Julio85 - 09-10-2018