Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Plug In file-heif-save
#1
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.
Reply
#2
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.


Attached Files
.zip   lenna-heif-example.zip (Size: 224 KB / Downloads: 185)
Reply
#3
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.
Reply
#4
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!!
Reply
#5
You are lucky, what I get from that plugin is:

Code:
/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.
Reply
#6
I was trying to use this plugin from external command line but could not figure it out. Confused

Luckily I found http://beefchunk.com/documentation/lang/...-script-fu

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.

convertJPGtoHEIF.scm:
Code:
(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)

  )
)

(script-fu-register    
  "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:

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

Hope it helps Big Grin .
Reply
#7
THANK YOU SO MUCH!!!

IT WORKS!!
Reply


Forum Jump: