I've recently looked into python scripting to automate an export process (involves handling layers and an alpha channel). I'd also like to give the user the ability to save an output dir so that the whole thing can be a 1-click process. My current thinking is that Image > Properties > Comment is the best place to store the path (I'm going to assume the user is saving as XCF).
The export path would be <image comment> + image filename (without extension) + ".dds"
I've been outputting things to the warning console to check the values are right, but with the above example something is wrong.
Code: Select all
from gimpfu import * import os def car_tex_export(image, drawable): #layer handling code here (works fine) #prepare for export process comment = pdb.gimp_image_get_parasite (image, "gimp-comment") #also tried: = image.parasite_find("gimp-comment") outdir = str(comment) #convert to string filename = os.path.splitext(image.name) #short filename without extension output_filename = os.path.join(outdir, filename + ".dds") #also tried: = outdir + "\\" + filename + ".dds" pdb.gimp_message(output_filename) #call export plugin eventually...
I could have it so that the comment has to be the full path to the file (e.g. C:\...\dir\filename.dds) but that lacks a bit of flexibility, e.g. if the user saves to a new filename and wants the exported file to match.
Any ideas about what can be done?