This was the case with Python 2 and the repo version of GIMP (2.8.22 on Ubuntu bionic).
I looked into building from source and found that setting up the dependencies to be a bit involved in terms of changing the server environment and can wait. 
Your interpretation is correct. The following works despite the warnings and resizes the file “/tmp/full.jpg” to something that is 600 pixels wide and saves the output to “/tmp/600.jpg”.
$ flatpak run org.gimp.GIMP//beta --no-interface -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import test;test.run()"
This is a development version of GIMP. Debug messages may appear here.
(gimp-2.99:2): Gdk-CRITICAL **: 17:37:15.840: gdk_atom_intern: assertion 'atom_name != NULL' failed
(gimp-2.99:2): Gdk-CRITICAL **: 17:37:15.841: gdk_atom_intern: assertion 'atom_name != NULL' failed
Gtk-Message: 17:37:16.051: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:37:16.054: Failed to load module "pk-gtk-module"
Gtk-Message: 17:37:16.094: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:37:16.095: Failed to load module "pk-gtk-module"
(python-eval.py:24): Gdk-CRITICAL **: 17:37:18.207: gdk_atom_intern: assertion 'atom_name != NULL' failed
(python-eval.py:24): Gdk-CRITICAL **: 17:37:18.215: gdk_atom_intern: assertion 'atom_name != NULL' failed
jpeg-save: saving image comment (17 bytes)
(file-jpeg:33): LibGimp-WARNING **: 17:37:23.628: file-jpeg: gimp_flush(): error: Broken pipe
batch command executed successfully
(gimp-2.99:2): Gimp-Core-WARNING **: 17:37:23.698: gimp_finalize: list of contexts not empty upon exit (4 contexts left)
stale context: (null)
stale context: PDB Context
stale context: (null)
stale context: PDB Context
(gimp-2.99:2): GEGL-WARNING **: 17:37:23.703: (../gegl/buffer/gegl-tile-handler-cache.c:1076):gegl_tile_cache_destroy: runtime check failed: (g_queue_is_empty (&cache_queue))
EEEEeEeek! 2 GeglBuffers leaked
To debug GeglBuffer leaks, set the environment variable GEGL_DEBUG to "buffer-alloc"
(script-fu:21): LibGimpBase-WARNING **: 17:37:23.954: script-fu: gimp_wire_read(): error
$ cat test.py
#!/usr/bin/env python
import gi;
from gi.repository import Gimp;
from gi.repository import GObject,Gio;
def run():
input_filepath = "/tmp/full.jpg"
output_filepath = "/tmp/600.jpg"
desired_width = 600
file_input = Gio.file_new_for_path(input_filepath);
file_output = Gio.file_new_for_path(output_filepath);
image = Gimp.get_pdb().run_procedure('gimp-file-load', [GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE), GObject.Value(Gio.File, file_input)])
if image.index(0) != Gimp.PDBStatusType.SUCCESS:
exit()
image = image.index(1)
layer = image.pick_correlate_layer(0,0)
image_width = image.get_width()
image_height = image.get_height()
if image_width > desired_width:
ratio = (desired_width + 0.0) / (image_width + 0.0)
image_width = desired_width
image_height = int(ratio * image_height)
if image_height == 0:
image_height = 1
Gimp.get_pdb().run_procedure('gimp-context-set-interpolation', [GObject.Value(GObject.TYPE_INT, 3)]) # no halo
Gimp.get_pdb().run_procedure('gimp-image-scale', [image, GObject.Value(GObject.TYPE_INT, image_width), GObject.Value(GObject.TYPE_INT, image_height)])
Gimp.get_pdb().run_procedure('file-jpeg-save', [GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE), image, GObject.Value(GObject.TYPE_INT, 1),GObject.Value(Gimp.ObjectArray, Gimp.ObjectArray.new(Gimp.Drawable, [layer], False)), GObject.Value(Gio.File, file_output), GObject.Value(GObject.TYPE_DOUBLE, 0.85), GObject.Value(GObject.TYPE_DOUBLE, 0), GObject.Value(GObject.TYPE_BOOLEAN, True), GObject.Value(GObject.TYPE_BOOLEAN, False), GObject.Value(GObject.TYPE_BOOLEAN, False), GObject.Value(GObject.TYPE_INT, 2), GObject.Value(GObject.TYPE_BOOLEAN, True), GObject.Value(GObject.TYPE_INT, 0), GObject.Value(GObject.TYPE_INT, 0)])
Thanks for generating a test build. gimp-console also appears to be interested in GTK:
$ flatpak run --command=gimp-console-2.99 org.gimp.GIMP//beta -df --batch-interpreter python-fu-eval
(gimp-console-2.99:2): GLib-GObject-WARNING **: 01:30:05.346: invalid unclassed type 'GimpCoreApp' in class cast to 'GObject'
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.347: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.347: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.348: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.348: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.348: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
(gimp-console-2.99:2): GLib-GObject-CRITICAL **: 01:30:05.348: g_object_class_override_property: assertion 'G_IS_OBJECT_CLASS (oclass)' failed
This is a development version of GIMP. Debug messages may appear here.
luajit: /app/share/lua/5.1/lgi/namespace.lua:189: gtk_init_check() failed
stack traceback:
[C]: in function 'error'
/app/share/lua/5.1/lgi/namespace.lua:189: in function 'require'
/app/share/lua/5.1/lgi/namespace.lua:170: in function '__index'
.../org.gimp.extension.goat-exercises/goat-exercise-lua.lua:28: in main chunk
[C]: at 0x565141e142e0
GIMP-WARNING: gimp-console-2.99: gimp_wire_read(): error
(script-fu:393): LibGimpBase-WARNING **: 01:30:13.510: script-fu: gimp_wire_read(): error
and
$ flatpak run --command=gimp-console-2.99 org.gimp.GIMP//beta -df --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import test;test.run()"
does not produce the expected output file.