Compare commits
1 Commits
f58ded8909
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6dcb63b541 |
@@ -33,7 +33,7 @@ i.e.
|
|||||||
- python main.py scribus input.csv palette
|
- python main.py scribus input.csv palette
|
||||||
- will generate a cmyk .xml for use with scribus
|
- will generate a cmyk .xml for use with scribus
|
||||||
- python main.py krita input.csv palette
|
- python main.py krita input.csv palette
|
||||||
- produces a krita resource bundle that is currently not working
|
- produces a krita resource bundle
|
||||||
|
|
||||||
Where "input_csv" would be your input csv as in swatchos.csv
|
Where "input_csv" would be your input csv as in swatchos.csv
|
||||||
|
|
||||||
@@ -52,6 +52,9 @@ Place the outputted xml file in /usr/share/scribus/swatches (you will need to su
|
|||||||
|
|
||||||
### Krita
|
### 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.
|
You can either place the .gpl generated by using the gpl format into $HOME/.local/share/krita/palettes.
|
||||||
|
or
|
||||||
|
|
||||||
**The current resource bundle for Krita does not load the palette correctly**
|
Use the Krita bundle and add via settings, manage resource libraries and then import from there
|
||||||
|
|
||||||
|
**TODO, add a preview picture for the bundle, this is likely o be something generic, possibly a logo?**
|
||||||
31
main.py
31
main.py
@@ -23,6 +23,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
import hashlib
|
import hashlib
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
def cmyk_to_hex(cp, mp, yp, kp):
|
def cmyk_to_hex(cp, mp, yp, kp):
|
||||||
c = int(cp * 2.55)
|
c = int(cp * 2.55)
|
||||||
@@ -81,24 +82,46 @@ def main(file_format, input, output):
|
|||||||
|
|
||||||
if file_format == "krita":
|
if file_format == "krita":
|
||||||
|
|
||||||
palette_hash = hashlib.md5(output_file_format).hexdigest()
|
hasher = hashlib.md5()
|
||||||
|
|
||||||
|
with open(output_file_format, "rb") as f:
|
||||||
|
for chunk in iter(lambda: f.read(4096), b""):
|
||||||
|
hasher.update(chunk)
|
||||||
|
|
||||||
|
palette_hash = hasher.hexdigest()
|
||||||
|
|
||||||
with open("mimetype", "w") as mt:
|
with open("mimetype", "w") as mt:
|
||||||
mt.write(f"application/x-krita-resourcebundle")
|
mt.write(f"application/x-krita-resourcebundle")
|
||||||
|
|
||||||
with open("meta.xml", "w") as meta:
|
with open("meta.xml", "w") as meta:
|
||||||
meta.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
|
meta.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||||
meta.write(f'<meta:meta>\n')
|
meta.write(f'<meta:meta xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1">\n')
|
||||||
|
meta.write(f'<meta:generator>Krita (6.0.1)</meta:generator>\n')
|
||||||
meta.write(f"<meta:bundle-version>1</meta:bundle-version>\n")
|
meta.write(f"<meta:bundle-version>1</meta:bundle-version>\n")
|
||||||
meta.write(f"<dc:author>CSV to Palette Generator</dc:author>\n")
|
meta.write(f"<dc:author>CSV to Palette Generator</dc:author>\n")
|
||||||
meta.write(f"<dc:description>Bundle Generated with CSV to Palette Generator</dc:description>\n")
|
meta.write(f'<dc:title>{output}</dc:title>\n')
|
||||||
meta.write(f"</meta:meta")
|
meta.write(f"<dc:description>{output} Bundle Generated with CSV to Palette Generator</dc:description>\n")
|
||||||
|
meta.write(f'<meta:inital-creator>{output} Generated with CSV to Palette Generator</meta:inital-creator>\n')
|
||||||
|
meta.write(f'<dc:creator>{output} Generated with CSV to Palette Generator</dc:creator>\n')
|
||||||
|
meta.write(f'<meta:creation-date>{datetime.now().strftime("%d/%m/%Y")}</meta:creation-date>\n')
|
||||||
|
meta.write(f'<meta:dc-date>{datetime.now().strftime("%d/%m/%Y")}</meta:dc-date>\n')
|
||||||
|
meta.write(f'<meta:email></meta:email>\n')
|
||||||
|
meta.write(f'<meta:license>CC-BY-SA</meta:license>\n')
|
||||||
|
meta.write(f'<meta:website></meta:website>\n')
|
||||||
|
meta.write(f'<meta:meta-userdefined meta:name="email" meta:value=""/>\n')
|
||||||
|
meta.write(f'<meta:meta-userdefined meta:name="license" meta:value="CC-BY-SA"/>\n')
|
||||||
|
meta.write(f'<meta:meta-userdefined meta:name="website" meta:value="http://"/>\n')
|
||||||
|
meta.write(f'</meta:meta>')
|
||||||
|
|
||||||
os.mkdir("META-INF")
|
os.mkdir("META-INF")
|
||||||
|
|
||||||
with open("manifest.xml", "w") as mani:
|
with open("manifest.xml", "w") as mani:
|
||||||
mani.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
|
mani.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||||
mani.write(f'<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">\n')
|
mani.write(f'<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">\n')
|
||||||
mani.write(f'<manifest:file-entry manifest:media-type="application/x-krita-resourcebundle" manifest:full-path="/"/>\n')
|
mani.write(f'<manifest:file-entry manifest:media-type="application/x-krita-resourcebundle" manifest:full-path="/"/>\n')
|
||||||
mani.write(f'<manifest:file-entry manifest:media-type="palettes" manifest:full-path="palettes/{output_file_format}" manifest:md5sum="{palette_hash}"/>\n')
|
mani.write(f'<manifest:file-entry manifest:media-type="palettes" manifest:full-path="palettes/{output_file_format}" manifest:md5sum="{palette_hash}"/>\n')
|
||||||
mani.write(f'</manifest:manifest>')
|
mani.write(f'</manifest:manifest>')
|
||||||
|
|
||||||
shutil.move("manifest.xml", "META-INF")
|
shutil.move("manifest.xml", "META-INF")
|
||||||
shutil.move(output_file_format, "palettes")
|
shutil.move(output_file_format, "palettes")
|
||||||
zipname = f"{output}.bundle"
|
zipname = f"{output}.bundle"
|
||||||
|
|||||||
Reference in New Issue
Block a user