diff --git a/README.md b/README.md index 320b01e..219d914 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Colour Name, C, M, Y, K, RGB Hex - gpl for GIMP and Inkscape - Scribus xml -- Krita kpl (coming soon) +- Krita Bundle ### Swatchos @@ -24,6 +24,7 @@ python main.py "file_format" "input_csv" "palette_name" Where "file_format" could be: - gpl : GIMP / Inkscape RGB Palette - scribus : Scribus CMYK XML Palette +- krita : Krita Resource Bundle Where "input_csv" would be your input csv as in swatchos.csv @@ -38,4 +39,6 @@ Place the exported .gpl in $HOME/.config/inkscape/palettes Place the exported .gpl in $HOME/.config/GIMP/$VERSION/palettes, where $VERSION is the gimp version ### Scribus -Place the outputted xml file in /usr/share/scribus/swatches (you will need to sudo or be root) \ No newline at end of file +Place the outputted xml file in /usr/share/scribus/swatches (you will need to sudo or be root) + +### Krita diff --git a/main.py b/main.py index 8d60cb1..85d4964 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,9 @@ import sys import csv +import os +import shutil +import zipfile def cmyk_to_hex(cp, mp, yp, kp): c = int(cp * 2.55) @@ -36,6 +39,8 @@ 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}.gpl" with open(input, newline='') as csvfile, open(output_file_format, "w") as out: code_reader = csv.reader(csvfile, delimiter=',') @@ -52,6 +57,7 @@ def main(file_format, input, output): g = int(hex[2:4], 16) b = int(hex[4:6], 16) out.write(f"{r} {g} {b} {row[0]}\n") + case "scribus": out.write(f'\n') out.write(f'\n') @@ -59,6 +65,40 @@ def main(file_format, input, output): hex = cmyk_to_hex(float(row[1]), float(row[2]), float(row[3]), float(row[4])) out.write(f'\n') out.write(f"") + + case "krita": + with open("mimetype", "w") as mt: + mt.write(f"application/x-krita-resourcebundle") + with open("meta.xml", "w") as meta: + meta.write(f'\n') + meta.write(f'\n') + meta.write(f"1\n") + meta.write(f"CSV to Palette Generator\n") + meta.write(f"Bundle Generated with CSV to Palette Generator\n") + meta.write(f"