Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List layers without loading image?
#11
(02-10-2021, 02:13 AM)eepjr24 Wrote:
(02-08-2021, 03:24 AM)ChameleonScales Wrote: Sure, what my plug-in does is from a given root directory and with a given maximum search depth, it finds all the xcfs and lists them in a csv table where each row is an xcf and each column is one of its layers (except the first column which is the url of the xcf).
Additionally, each "layer cell" of the csv contains the visibility state of the layer (whether the eye is open or closed) by inserting an identifiable string at the start of the cell.

Right now it works by using the Gimp api and I've started making a GTK dialog to make your "super-fast" version work outside of Gimp with the same functionalities.

I actually forgot to mention that "visibility" part, sorry about that (*∩▂∩). So right now I'm missing that from your version.
If it even is possible, do you perhaps know how to do that? (º̩̩́⌣º̩̩̀ʃƪ)

Consider my answer just a pointer in the right direction until tmanni or someone else who knows the xcf format can chime in. I think what you are looking for is:

PROP_VISIBLE (essential)
 uint32  8   The type number for PROP_VISIBLE is 8
 uint32  4   Four bytes of payload
 uint32  b   1 if the layer/channel is visible; 0 if not


I pulled this from HERE, which is a partial XCF specification that will probably come in handy for the type of work you look to be doing. I only dabble in Python, so I'm not going to attempt to give a code example, but you are reading the layer name and the property list follows it immediately in the file:

 string  name   The name of the layer
 property-list  Layer properties (details below)

That means from the name you should be able to seek N bytes forward in the file (where N is the sum of the bytes of the properties until the PROP_VISIBLE flag) and read / convert it (I think bitstring would be okay for this). Again, this is just to help you along in the mean time, I am no expert.


- E 

Note tha there are currently two XCF formats, the up-to-2.8 one and the 2.10-onwards one, that supports (among other things) more channel blend modes and high-precision data. Not sure it matters here, but not sure it doesn't either...
Reply
#12
IMO the most up to date xcf specification is here : https://gitlab.gnome.org/GNOME/gimp/-/bl...cs/xcf.txt
The gimp c code which open an xcf file and load it is here : https://gitlab.gnome.org/GNOME/gimp/-/bl...oad.c#L161

@ChameleonScales, do you read C language ? If the answer is yes, with a bit of work, you should be able to retrieve any information from a xcf file by completing the python script I posted.
Reply
#13
@Ofnuts: I'll focus on the most up-to-date stable version
@tmanni: Sorry, I have no knowledge in C and given the investment it represents, I don't have a plan to learn it atm.
I haven't even figured out how to complete your python script to include the layer visibility. bitstring reading is all new to me.
Reply
#14
(02-11-2021, 06:22 PM)ChameleonScales Wrote: @Ofnuts: I'll focus on the most up-to-date stable version
@tmanni: Sorry, I have no knowledge in C and given the investment it represents, I don't have a plan to learn it atm.
I haven't even figured out how to complete your python script to include the layer visibility. bitstring reading is all new to me.

Reading C is easy, it's writing it which is complicated Smile
Reply
#15
Sorry to bother you again but I'm still clueless about how to print out the layer visibility from reading the binary data and that's the only thing missing to complete my plugin and publish it on gitlab.

Could anyone help?
Reply


Forum Jump: