Fixed Scribus Compatibility
This commit is contained in:
18
main.py
18
main.py
@@ -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>")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user