09-21-2021, 12:44 AM
Thanks, I went on IRC and Akkana Peck (akk) solved it!
Here is the result (it also prints out which is the active layer as a bonus):
Here is the result (it also prints out which is the active layer as a bonus):
Code:
#!/usr/bin/env python3
import sys
PROP_ACTIVE_LAYER = 2
PROP_VISIBLE = 8
if __name__ == "__main__":
filename = sys.argv[1]
# open the file in readonly binary mode
with open(filename, 'rb') as f:
# go to the 30th bytes
f.seek(30, 0)
# read properties
while True:
prop_type = int.from_bytes(f.read(4), "big")
prop_size = int.from_bytes(f.read(4), "big")
f.read(prop_size)
if prop_type == 0: #PROP_END
break
# read layers
while True:
next_layer_offset = int.from_bytes(f.read(8), "big")
if not next_layer_offset: #end of layers offsets
break;
saved_pos = f.tell()
f.seek(next_layer_offset + 12, 0)
tmp = int.from_bytes(f.read(4), "big")
name = f.read(tmp).decode("utf-8")
print()
print(name)
while True:
prop_type = int.from_bytes(f.read(4), "big")
prop_size = int(int.from_bytes(f.read(4), "big") / 4)
# print(prop_type, "size", prop_size)
for i in range(prop_size):
lastint = int.from_bytes(f.read(4), "big")
if prop_type == PROP_VISIBLE:
print("Visible? %x" % lastint)
break
elif prop_type == PROP_ACTIVE_LAYER:
print("Active")
f.seek(saved_pos, 0)