It is currently 13 Jul 2020, 16:59

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Image comment (parasite) concatenation?

Share your Python Fu Scripts/plug-ins for GIMP here
Post Reply
R Soul
Newly Registered

Image comment (parasite) concatenation?

Post#1 by R Soul » 13 Apr 2020, 12:47


Hi all.

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.

Example code:

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)[0] #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...
The line pdb.gimp_message(output_filename) only prints the value of outdir. You'll see from the comments that I've tried a couple of ways of getting the comment, and a couple of ways of joining the strings together, but the results are the same no matter what I try. What's also strange is that if I hardcode it, e.g outdir = "Test folder", both types of joining work fine.

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?
GIMP Learn rocks...
0

tim
GL Blogger

Post#2 by tim » 19 Apr 2020, 05:28


I don't know if this helps or not: I always had a difficult time working with parasite....so
I wrote this down long time ago for future reference
viewtopic.php?f=3&t=542&p=3742
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

skinnyhouse
Script Coder

Post#3 by skinnyhouse » 21 Apr 2020, 09:01


This sort of stuff is above my pay grade but:

I used parasites to save a temporary copy of filepath information for the number of files within a directory and had to store the various filepaths in within a list. Not tried out your problem but perhaps worth investigating. Best of luck!
0


GIMP/GL:  Tutorials | Tips | Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  🡆 Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 15 guests