Fixed Scribus Compatibility

This commit is contained in:
2026-04-09 17:35:58 +01:00
parent ed662b285c
commit bd4fdaf20f
3 changed files with 917 additions and 913 deletions

18
main.py
View File

@@ -1,6 +1,15 @@
import sys
import csv
def cmyk_to_hex(cp, mp, yp, kp):
c = int(cp * 2.55)
m = int(mp * 2.55)
y = int(yp * 2.55)
k = int(kp * 2.55)
return "#{:02x}{:02x}{:02x}{:02x}".format(c,m,y,k)
def main(file_format, input, output):
output_file_format = ""
@@ -10,8 +19,6 @@ def main(file_format, input, output):
output_file_format = f"{output}.gpl"
case "scribus":
output_file_format = f"{output}.xml"
case: "krita":
output_file_format = f"{output}.kpl"
with open(input, newline='') as csvfile, open(output_file_format, "w") as out:
code_reader = csv.reader(csvfile, delimiter=',')
@@ -32,11 +39,8 @@ def main(file_format, input, output):
out.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
out.write(f'<SCRIBUSCOLORS Name="{output}">\n')
for row in code_reader:
c = float(row[1])/100
m = float(row[2])/100
y = float(row[3])/100
k = float(row[4])/100
out.write(f'<COLOR Spot="0" Register="0" Name="{row[0]}" CMYK="{c} {m} {y} {k}"/>\n')
hex = cmyk_to_hex(float(row[1]), float(row[2]), float(row[3]), float(row[4]))
out.write(f'<COLOR Spot="0" Register="0" Name="{row[0]}" CMYK="{hex}"/>\n')
out.write(f"</SCRIBUSCOLORS>")