09-26-2020, 09:15 PM
(09-26-2020, 10:29 AM)rich2005 Wrote: @Ofnuts - question about xcf format comment
This a shell using your two lines of code.
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# adds a comment
import re, os, sys
from gimpfu import *
def add_comment (image,drawable,comment):
if not comment:
comment="no comment "
p=gimp.Parasite('gimp-comment',0,comment)
image.parasite_attach(p)
else:
p=gimp.Parasite('gimp-comment',0,comment)
image.parasite_attach(p)
register(
"python_fu_add_comment",
" ",
" ",
"",
" ",
"2020",
"<Image>/Tools/add comment",
"*",
[
(PF_TEXT, "comment", "new comment", "")
],
[],
add_comment,
)
main()
Using this on a png file (same with jpeg)
Files has default comment - new comment added using script - png exported - file closed - opened again - comment is there. https://i.imgur.com/6QvhWWr.mp4
Same procedure but using xcf format. The comment is not saved (or is it lost when the xcf is reopened?) Whichever way the comment has gone. https://i.imgur.com/QhoiZ67.mp4
A diagonal look across the source code hints that the 2nd argument is a parasite "type", and a collection of C constants related to Gimp parasites says #define GIMP_PARASITE_PERSISTENT 1|, and indeed, using 1 instead of 0 seems to make the parasite survive in a saved XCF.
Code:
p=gimp.Parasite('gimp-comment',1,'(C) Ofnuts from python-fu')
image.parasite_attach(p)