From f58ded8909ed26ca2085d96811fa364a96d4c90b Mon Sep 17 00:00:00 2001 From: ProtoPenguin Date: Thu, 9 Apr 2026 19:40:03 +0100 Subject: [PATCH] Added manifests to Krita resource bundler, updated docs --- README.md | 15 ++++++++++++++- main.py | 37 ++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 219d914..e9fe9a0 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,22 @@ This will be able to be used with any CSV that follows the example Currently this should run on any version of python 3 or above -python main.py "file_format" "input_csv" "palette_name" +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 +i.e. + +- python main.py gpl input.csv palette + - will produce a rgb .gpl for use in Inkscape, GIMP and Krita +- python main.py scribus input.csv palette + - will generate a cmyk .xml for use with scribus +- python main.py krita input.csv palette + - produces a krita resource bundle that is currently not working + Where "input_csv" would be your input csv as in swatchos.csv Where "palette_name" is the name of your palette, the required extension is added automatically @@ -42,3 +51,7 @@ Place the exported .gpl in $HOME/.config/GIMP/$VERSION/palettes, where $VERSION Place the outputted xml file in /usr/share/scribus/swatches (you will need to sudo or be root) ### Krita + +While I am working on the resource bundle for Krita, you can place the .gpl generated by using the gpl format into $HOME/.local/share/krita/palettes. + +**The current resource bundle for Krita does not load the palette correctly** \ No newline at end of file diff --git a/main.py b/main.py index 85d4964..6f59c18 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,7 @@ import csv import os import shutil import zipfile +import hashlib def cmyk_to_hex(cp, mp, yp, kp): c = int(cp * 2.55) @@ -67,16 +68,6 @@ def main(file_format, input, output): 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"\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"\n') + mani.write(f'\n') + mani.write(f'\n') + mani.write(f'\n') + mani.write(f'') + shutil.move("manifest.xml", "META-INF") shutil.move(output_file_format, "palettes") zipname = f"{output}.bundle" with zipfile.ZipFile(zipname, "w") as zippy: @@ -95,11 +107,14 @@ def main(file_format, input, output): zippy.write("mimetype") zippy.write("palettes") zippy.write("palettes/" + output_file_format) + zippy.write("META-INF") + zippy.write("META-INF/manifest.xml") os.remove("mimetype") os.remove("meta.xml") os.remove("palettes/" + output_file_format) os.removedirs("palettes") - + os.remove("META-INF/manifest.xml") + os.removedirs("META-INF") if __name__ == "__main__":