02-12-2023, 01:27 PM
(This post was last modified: 02-12-2023, 01:58 PM by Anthony Buff.)
(02-12-2023, 09:46 AM)Ofnuts Wrote: See my remark above about the availability of the Python support in Gimp in recent Linux distros.
You will know you have a working Python support when you have a working Filters > Python-fu > Console in the UI.
FWIW
(02-12-2023, 12:39 AM)Ofnuts Wrote: You don't need to open the UI(*), you can use Gimp+Python in batch mode from a shell (or shell script), but your script still has to start a Gimp process and tell it to run your Python. See this example.
This is what I tried to do here:
Code:
gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['/home/Kaitlyn/Desktop']+sys.path;import ChangeGimpTextLayersSample;ChangeGimpTextLayersSample.run('/home/User/Desktop/FieldSheet.xcf')" -b "pdb.gimp_quit(1)"
Code:
import sys
import os
import traceback
import logging
from gimpfu import *
import gimpcolor
from collections import namedtuple
logging.basicConfig(filename='/home/User/Desktop/gimp_script_log.log', level=logging.DEBUG)
file_path = "/home/User/Desktop/FieldSheet.xcf"
if os.path.exists(file_path):
logging.debug("Found FieldSheet.xcf")
image = pdb.gimp_xcf_load(0, file_path, file_path)
layers = image.layers
for layer in layers:
if layer.name == "ChangeMe":
logging.debug("Found ChangeMe layer")
pdb.gimp_text_layer_set_text(layer, "Testing Script")
pdb.gimp_xcf_save(0, image, image.active_layer, "/home/User/Desktop/test.xcf", "test.xcf")
logging.debug("Finished processing FieldSheet.xcf")
else:
logging.debug("The file does not exist.")