Optionsschalter vereinheitlicht, .sh-Skripte von überall aufrufbar
- gleiche Aufgabe = gleicher Schalter in allen Programmen: -c/--config (Alias --cfg), -i, -o/--outdir, --section, --format, -f/--force, -j, -t/--test, -y/--dry, -v - svgconvert: -o statt -s (Alias --svgfolder), --section statt --format für die Sektion (Standard png), --format überschreibt das Bildformat - webscan: --timeout und --browser nur noch lang (kollidierten mit -t/-b) - glyphextract: -i nimmt Glyph oder Font, -e extrahiert (statt -f/-t) - setenv.sh ermittelt das Projektverzeichnis selbst, alle .sh laden es relativ zum Skript; extract-font/fonttest reichen weitere Optionen durch - Hilfetexte korrigiert, doc/README.md: Abschnitt "Gemeinsame Optionen" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
28f2bcdb32
commit
6bdaa62a7d
@@ -6,5 +6,5 @@ if "%~1"=="" (
|
|||||||
echo please give a directory in the in folder with .svg glyphs as input
|
echo please give a directory in the in folder with .svg glyphs as input
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
"%PICCREATE_PYTHON%" "%PICCREATE_LIBS%\glyphextract.py" -f %1
|
"%PICCREATE_PYTHON%" "%PICCREATE_LIBS%\glyphextract.py" -i %1 -e %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "please give a directory in the in folder with .svg glyphs as input"
|
echo "please give a directory in the in folder with .svg glyphs as input"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Glyphen und <font>.cfg eines Fonts nach $PICCREATE_OUT schreiben
|
# Glyphen und <font>.cfg eines Fonts nach $PICCREATE_OUT schreiben
|
||||||
python3 $PICCREATE_LIBS/glyphextract.py -f "$1"
|
python3 $PICCREATE_LIBS/glyphextract.py -i "$1" -e "${@:2}"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
# Einen Buchstaben extrahieren
|
# Einen Buchstaben extrahieren
|
||||||
# extract-glyph.sh -i ../in/ausgangsschrift/a.svg Testbild fuer Inkscape
|
# extract-glyph.sh -i ../in/ausgangsschrift/a.svg Testbild fuer Inkscape
|
||||||
|
|||||||
+1
-1
@@ -6,5 +6,5 @@ if "%~1"=="" (
|
|||||||
echo please give a directory in the in folder with .svg glyphs as input
|
echo please give a directory in the in folder with .svg glyphs as input
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
"%PICCREATE_PYTHON%" "%PICCREATE_LIBS%\glyphextract.py" -t %1
|
"%PICCREATE_PYTHON%" "%PICCREATE_LIBS%\glyphextract.py" -i %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "please give a directory in the in folder with .svg glyphs as input"
|
echo "please give a directory in the in folder with .svg glyphs as input"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Testbilder aller Glyphen eines Fonts nach $PICCREATE_OUT schreiben
|
# Testbilder aller Glyphen eines Fonts nach $PICCREATE_OUT schreiben
|
||||||
python3 $PICCREATE_LIBS/glyphextract.py -t "$1"
|
python3 $PICCREATE_LIBS/glyphextract.py -i "$1" "${@:2}"
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
# Startet das Programm
|
# Startet das Programm
|
||||||
python3 $PICCREATE_LIBS/piccreate.py "$@"
|
python3 $PICCREATE_LIBS/piccreate.py "$@"
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,8 @@
|
|||||||
if [ ! -z $PICCREATE ];then
|
if [ ! -z $PICCREATE ];then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
export PICCREATE=~/develop/python/piccreate
|
# das Verzeichnis ueber bin/
|
||||||
|
export PICCREATE=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/.." && pwd)
|
||||||
echo setting environment to $PICCREATE
|
echo setting environment to $PICCREATE
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
# SVG Bilder mit ImageMagick in JPG/PNG umwandeln
|
# SVG Bilder mit ImageMagick in JPG/PNG umwandeln
|
||||||
# svgconvert.sh -c punkteraetsel --format png -p
|
# svgconvert.sh -c punkteraetsel -p
|
||||||
python3 $PICCREATE_LIBS/svgconvert.py "$@"
|
python3 $PICCREATE_LIBS/svgconvert.py "$@"
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. setenv.sh
|
. "$(dirname "${BASH_SOURCE[0]}")/setenv.sh"
|
||||||
|
|
||||||
# Vorschaubilder von Webseiten erzeugen (Playwright, Python-venv im Projekt)
|
# Vorschaubilder von Webseiten erzeugen (Playwright, Python-venv im Projekt)
|
||||||
PYTHON=python3
|
PYTHON=python3
|
||||||
|
|||||||
+52
-14
@@ -43,14 +43,37 @@ Alles läuft unter Linux und Windows, siehe [Windows](#windows).
|
|||||||
|
|
||||||
Alle Pfade werden über Umgebungsvariablen gefunden, die `bin/setenv.sh` setzt
|
Alle Pfade werden über Umgebungsvariablen gefunden, die `bin/setenv.sh` setzt
|
||||||
(`PICCREATE`, `PICCREATE_CFG`, `PICCREATE_IN`, `PICCREATE_OUT`,
|
(`PICCREATE`, `PICCREATE_CFG`, `PICCREATE_IN`, `PICCREATE_OUT`,
|
||||||
`PICCREATE_FONTS`, `PICCREATE_BACKGROUNDS`, …). Der Installationspfad steht
|
`PICCREATE_FONTS`, `PICCREATE_BACKGROUNDS`, …). Das Projektverzeichnis ermittelt
|
||||||
dort fest auf `~/develop/python/piccreate`.
|
`setenv.sh` selbst (das Verzeichnis über `bin/`), die Skripte in `bin/` lassen
|
||||||
|
sich deshalb von überall aufrufen. Nur wer die Variablen in der eigenen Shell
|
||||||
|
braucht, lädt `setenv.sh` selbst (bash oder zsh):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd bin
|
cd bin
|
||||||
. ./setenv.sh
|
. ./setenv.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Gemeinsame Optionen
|
||||||
|
|
||||||
|
Alle Programme benutzen für dieselbe Aufgabe denselben Schalter:
|
||||||
|
|
||||||
|
| Option | Bedeutung | piccreate | svgconvert | webscan | glyphextract |
|
||||||
|
|---------------------|----------------------------------------------------|:-:|:-:|:-:|:-:|
|
||||||
|
| `-c`, `--config` | Konfiguration aus `cfg/` (Endung `.cfg` optional) | ✓ | ✓ | ✓ | |
|
||||||
|
| `-i`, `--infile` | Eingabe (CSV, URL-Liste, Glyph oder Font) | ✓ | ✓ | ✓ | ✓ |
|
||||||
|
| `-o`, `--outdir` | Ordner für die erzeugten Bilder (Standard `$PICCREATE_OUT`) | ✓ | ✓ | ✓ | ✓ |
|
||||||
|
| `--section` | Sektion der Konfiguration mit den Bildmaßen | | ✓ | ✓ | |
|
||||||
|
| `--format` | Bildformat `jpg` oder `png` (überschreibt die Konfiguration) | | ✓ | ✓ | |
|
||||||
|
| `-f`, `--force` | vorhandene Bilder überschreiben | | ✓ | ✓ | |
|
||||||
|
| `-j`, `--jobs` | Anzahl paralleler Jobs | | ✓ | ✓ | |
|
||||||
|
| `-t`, `--test` | Testbilder erzeugen | | ✓ | | |
|
||||||
|
| `-y`, `--dry` | Probelauf, keine Dateien schreiben | ✓ | ✓ | | |
|
||||||
|
| `-v`, `--verbose` | ausführliche Ausgabe | | ✓ | ✓ | |
|
||||||
|
| `-h`, `--help` | Hilfe | ✓ | ✓ | ✓ | ✓ |
|
||||||
|
|
||||||
|
Ältere Namen funktionieren weiter: `--cfg` für `--config` und bei svgconvert
|
||||||
|
`--svgfolder` für `--outdir`.
|
||||||
|
|
||||||
## Bilder erzeugen
|
## Bilder erzeugen
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -59,7 +82,7 @@ cd bin
|
|||||||
|
|
||||||
| Option | Bedeutung |
|
| Option | Bedeutung |
|
||||||
|-------------------|------------------------------------------------------------|
|
|-------------------|------------------------------------------------------------|
|
||||||
| `-c`, `--cfg` | Konfiguration aus `cfg/` (Endung `.cfg` optional) |
|
| `-c`, `--config` | Konfiguration aus `cfg/` (Endung `.cfg` optional) |
|
||||||
| `-i`, `--infile` | CSV-Datei aus `in/` (Endung `.csv` optional) |
|
| `-i`, `--infile` | CSV-Datei aus `in/` (Endung `.csv` optional) |
|
||||||
| `-o`, `--outdir` | Ausgabeverzeichnis (Standard: `$PICCREATE_OUT`) |
|
| `-o`, `--outdir` | Ausgabeverzeichnis (Standard: `$PICCREATE_OUT`) |
|
||||||
| `-s`, `--startfrom` | Nummerierung bei jedem Wort / Großbuchstaben neu beginnen |
|
| `-s`, `--startfrom` | Nummerierung bei jedem Wort / Großbuchstaben neu beginnen |
|
||||||
@@ -129,22 +152,26 @@ Die Sektionen `[jpgs]`, `[png]` usw. beschreiben die Rastergrafiken für
|
|||||||
## SVG in JPG/PNG umwandeln
|
## SVG in JPG/PNG umwandeln
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./svgconvert.sh -c punkteraetsel --format png -p
|
./svgconvert.sh -c punkteraetsel -p
|
||||||
```
|
```
|
||||||
|
|
||||||
Wandelt alle SVGs in `$PICCREATE_OUT` (oder `-s <ordner>`) parallel mit
|
Wandelt alle SVGs in `$PICCREATE_OUT` (oder `-o <ordner>`) parallel mit
|
||||||
ImageMagick um. `--format` wählt die Sektion aus der Konfiguration.
|
ImageMagick um; die Bilder landen im selben Ordner. Breite, Höhe, Format und
|
||||||
|
Auflösung kommen aus der Sektion `--section` der Konfiguration (Standard
|
||||||
|
`[png]`, für große JPGs z. B. `--section jpgs`).
|
||||||
|
|
||||||
| Option | Bedeutung |
|
| Option | Bedeutung |
|
||||||
|-----------------|--------------------------------------------------------|
|
|-----------------|--------------------------------------------------------|
|
||||||
| `-c` | Konfiguration aus `cfg/` (Endung `.cfg` optional) |
|
| `-c` | Konfiguration aus `cfg/` (Endung `.cfg` optional) |
|
||||||
| `--format` | Sektion/Format, z. B. `png` oder `jpgs` (Standard `jpg`) |
|
| `-o` | Ordner mit den SVGs, auch für die Bilder (Standard `$PICCREATE_OUT`) |
|
||||||
|
| `--section` | Sektion mit den Bildmaßen (Standard `png`) |
|
||||||
|
| `--format` | `jpg` oder `png` (überschreibt die Konfiguration) |
|
||||||
| `-i` | CSV aus `in/` prüfen: fehlende Bilder melden, nur diese umwandeln |
|
| `-i` | CSV aus `in/` prüfen: fehlende Bilder melden, nur diese umwandeln |
|
||||||
| `-j` | Anzahl paralleler Jobs (Standard 8) |
|
| `-j` | Anzahl paralleler Jobs (Standard 8) |
|
||||||
| `-b` | Hintergrundfarbe, `none` für transparent |
|
| `-b` | Hintergrundfarbe, `none` für transparent |
|
||||||
| `-f` | vorhandene Bilder überschreiben |
|
| `-f` | vorhandene Bilder überschreiben |
|
||||||
| `-p` / `-v` | Fortschrittsbalken / ausführliche Ausgabe |
|
| `-p` / `-v` | Fortschrittsbalken / ausführliche Ausgabe |
|
||||||
| `-s` | Ordner mit den SVGs (Standard `$PICCREATE_OUT`) |
|
| `-t <n>` | `n` Test-SVGs erzeugen und umwandeln |
|
||||||
| `-y` | Probelauf ohne Umwandlung |
|
| `-y` | Probelauf ohne Umwandlung |
|
||||||
|
|
||||||
## Vorschaubilder von Webseiten (webscan)
|
## Vorschaubilder von Webseiten (webscan)
|
||||||
@@ -182,7 +209,7 @@ besser das Chromium der Distribution):
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo pacman -S chromium
|
sudo pacman -S chromium
|
||||||
export PICCREATE_BROWSER=/usr/bin/chromium # oder Option -b /usr/bin/chromium
|
export PICCREATE_BROWSER=/usr/bin/chromium # oder Option --browser /usr/bin/chromium
|
||||||
```
|
```
|
||||||
|
|
||||||
Fehlen Playwright oder der Browser, gibt `webscan.py` die passenden Befehle
|
Fehlen Playwright oder der Browser, gibt `webscan.py` die passenden Befehle
|
||||||
@@ -208,11 +235,12 @@ Aufruf:
|
|||||||
| `-c` | Konfiguration (Standard `webscan`) |
|
| `-c` | Konfiguration (Standard `webscan`) |
|
||||||
| `-i` | Eingabedatei aus `in/` oder mit Pfad |
|
| `-i` | Eingabedatei aus `in/` oder mit Pfad |
|
||||||
| `-o` | Ausgabeverzeichnis (Standard `$PICCREATE_OUT`) |
|
| `-o` | Ausgabeverzeichnis (Standard `$PICCREATE_OUT`) |
|
||||||
|
| `--section` | Sektion mit den Bildmaßen (Standard `webscan`) |
|
||||||
| `--format` | `jpg` oder `png` (überschreibt die Konfiguration) |
|
| `--format` | `jpg` oder `png` (überschreibt die Konfiguration) |
|
||||||
| `-j` | Anzahl gleichzeitig geladener Seiten (Standard 4) |
|
| `-j` | Anzahl gleichzeitig geladener Seiten (Standard 4) |
|
||||||
| `-t` | Wartezeit pro Seite in Sekunden (Standard 20) |
|
| `--timeout` | Wartezeit pro Seite in Sekunden (Standard 20) |
|
||||||
| `-f` | vorhandene Bilder überschreiben |
|
| `-f` | vorhandene Bilder überschreiben |
|
||||||
| `-b` | Pfad zu einem eigenen Chromium |
|
| `--browser` | Pfad zu einem eigenen Chromium |
|
||||||
| `-v` | ausführliche Ausgabe |
|
| `-v` | ausführliche Ausgabe |
|
||||||
|
|
||||||
Seiten ohne URL oder mit Ladefehler werden übersprungen und am Ende
|
Seiten ohne URL oder mit Ladefehler werden übersprungen und am Ende
|
||||||
@@ -248,8 +276,18 @@ Nummern als Text `x1`, `x2`, …):
|
|||||||
./extract-glyph.sh -i ../in/ausgangsschrift/a.svg -e # nur ein Buchstabe
|
./extract-glyph.sh -i ../in/ausgangsschrift/a.svg -e # nur ein Buchstabe
|
||||||
```
|
```
|
||||||
|
|
||||||
Alle drei rufen `libs/glyphextract.py` auf (`-f`, `-t` bzw. `-i [-e]`) und
|
Alle drei rufen `libs/glyphextract.py` auf. Dort ist `-i` ein einzelner
|
||||||
schreiben nach `$PICCREATE_OUT` (oder `-o <ordner>`). Das Ergebnis
|
Buchstabe oder ein Font (Ordner in `in/` oder Pfad); mit `-e` werden die
|
||||||
|
Glyphen für den Font extrahiert (bei einem Font zusätzlich `<name>.cfg`),
|
||||||
|
ohne `-e` entstehen Testbilder zum Prüfen in Inkscape:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 glyphextract.py -i ausgangsschrift -e # = extract-font.sh
|
||||||
|
python3 glyphextract.py -i ausgangsschrift # = fonttest.sh
|
||||||
|
python3 glyphextract.py -i ../in/ausgangsschrift/a.svg -e
|
||||||
|
```
|
||||||
|
|
||||||
|
Alle schreiben nach `$PICCREATE_OUT` (oder `-o <ordner>`). Das Ergebnis
|
||||||
(Glyph-SVGs und `<name>.cfg`) wird anschließend nach `fonts/<name>/`
|
(Glyph-SVGs und `<name>.cfg`) wird anschließend nach `fonts/<name>/`
|
||||||
übernommen. Werte wie `XSTEP` kann man danach in der `.cfg` noch von Hand
|
übernommen. Werte wie `XSTEP` kann man danach in der `.cfg` noch von Hand
|
||||||
anpassen.
|
anpassen.
|
||||||
@@ -275,7 +313,7 @@ Beispiel:
|
|||||||
```bat
|
```bat
|
||||||
cd bin
|
cd bin
|
||||||
piccreate.bat -c punkteraetsel -i test
|
piccreate.bat -c punkteraetsel -i test
|
||||||
svgconvert.bat -c punkteraetsel --format png -p
|
svgconvert.bat -c punkteraetsel -p
|
||||||
```
|
```
|
||||||
|
|
||||||
Die `.bat`-Dateien nehmen das Python aus `.venv`, falls vorhanden, sonst den
|
Die `.bat`-Dateien nehmen das Python aus `.venv`, falls vorhanden, sonst den
|
||||||
|
|||||||
+19
-22
@@ -178,26 +178,26 @@ def main():
|
|||||||
print('"' + out_dir + '" does not exist. Please give the directory for the output!')
|
print('"' + out_dir + '" does not exist. Please give the directory for the output!')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if options.infile:
|
if os.path.isfile(options.infile):
|
||||||
# ein Buchstabe (extract-glyph.sh)
|
# ein Buchstabe (extract-glyph.sh)
|
||||||
if not os.path.isfile(options.infile) or not os.path.getsize(options.infile):
|
if not os.path.getsize(options.infile):
|
||||||
print('input file does not exist')
|
print('input file is empty')
|
||||||
return 1
|
return 1
|
||||||
base, config = write_glyph(options.infile, out_dir, options.extract)
|
base, config = write_glyph(options.infile, out_dir, options.extract)
|
||||||
with open(os.path.join(out_dir, base + '.cfg'), 'w', encoding='utf-8', newline='\n') as fh:
|
with open(os.path.join(out_dir, base + '.cfg'), 'w', encoding='utf-8', newline='\n') as fh:
|
||||||
fh.write(config)
|
fh.write(config)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
name = options.font or options.test
|
# alle Buchstaben eines Fonts
|
||||||
source = font_source(name)
|
source = font_source(options.infile)
|
||||||
configs = []
|
configs = []
|
||||||
for svg_path in sorted_glyphs(source):
|
for svg_path in sorted_glyphs(source):
|
||||||
base, config = write_glyph(svg_path, out_dir, extract=bool(options.font))
|
base, config = write_glyph(svg_path, out_dir, options.extract)
|
||||||
print(base)
|
print(base)
|
||||||
configs.append((base, config))
|
configs.append((base, config))
|
||||||
|
|
||||||
if options.font:
|
if options.extract:
|
||||||
# ein Font (extract-font.sh): alle Sektionen in <font>.cfg
|
# Font (extract-font.sh): alle Sektionen in <font>.cfg
|
||||||
cfg_name = os.path.basename(os.path.normpath(source)) + '.cfg'
|
cfg_name = os.path.basename(os.path.normpath(source)) + '.cfg'
|
||||||
with open(os.path.join(out_dir, cfg_name), 'w', encoding='utf-8', newline='\n') as fh:
|
with open(os.path.join(out_dir, cfg_name), 'w', encoding='utf-8', newline='\n') as fh:
|
||||||
fh.write(''.join(config for _, config in configs))
|
fh.write(''.join(config for _, config in configs))
|
||||||
@@ -211,36 +211,33 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = optparse.OptionParser(usage="""%prog [options]
|
parser = optparse.OptionParser(usage="""%prog -i <glyph.svg | font> [-e] [options]
|
||||||
|
|
||||||
Example usage
|
Example usage
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
one glyph, to test it later with inkscape:
|
one glyph, test picture to check it with inkscape:
|
||||||
$ %prog -i ../in/ausgangsschrift/a.svg
|
$ %prog -i ../in/ausgangsschrift/a.svg
|
||||||
one glyph, extract the points and text for the font:
|
one glyph, extract the points and text for the font:
|
||||||
$ %prog -i ../in/ausgangsschrift/a.svg -e
|
$ %prog -i ../in/ausgangsschrift/a.svg -e
|
||||||
all glyphs of a font (directory in in/) including the font config:
|
all glyphs of a font (directory in in/ or a path) including the font config:
|
||||||
$ %prog -f ausgangsschrift
|
$ %prog -i ausgangsschrift -e
|
||||||
test pictures of all glyphs of a font:
|
test pictures of all glyphs of a font:
|
||||||
$ %prog -t ausgangsschrift
|
$ %prog -i ausgangsschrift
|
||||||
""", version='%prog ' + __version__)
|
""", version='%prog ' + __version__)
|
||||||
|
|
||||||
parser.add_option("-i", "--infile", dest="infile",
|
parser.add_option("-i", "--infile", dest="infile",
|
||||||
help="svg file of one glyph")
|
help="svg file of one glyph or directory with the glyphs of a font")
|
||||||
parser.add_option("-e", "--extract", dest="extract", action='store_true', default=False,
|
parser.add_option("-e", "--extract", dest="extract", action='store_true', default=False,
|
||||||
help="with -i: extract the glyph for the font instead of a test picture")
|
help="extract the glyphs for the font (and write <font>.cfg) "
|
||||||
parser.add_option("-f", "--font", dest="font",
|
"instead of test pictures")
|
||||||
help="directory with the glyphs of a font: create glyphs and font config")
|
|
||||||
parser.add_option("-t", "--test", dest="test",
|
|
||||||
help="directory with the glyphs of a font: create test pictures")
|
|
||||||
parser.add_option("-o", "--outdir", dest="outdir",
|
parser.add_option("-o", "--outdir", dest="outdir",
|
||||||
default=os.environ.get('PICCREATE_OUT', '.'),
|
default=os.environ.get('PICCREATE_OUT', '.'),
|
||||||
help="directory for the output. default is $PICCREATE_OUT")
|
help="directory where the files will be written. default is $PICCREATE_OUT")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if sum(1 for o in (options.infile, options.font, options.test) if o) != 1:
|
if not options.infile:
|
||||||
parser.error('please give exactly one of -i, -f or -t')
|
parser.error('please give a glyph or a font with -i')
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
# vim: set tw=80 ft=python ts=4 sw=4:
|
# vim: set tw=80 ft=python ts=4 sw=4:
|
||||||
|
|||||||
+5
-5
@@ -370,20 +370,20 @@ Read Confg, create wakeup and scale this kind of jiffy box
|
|||||||
|
|
||||||
""", version='%prog ' + __version__)
|
""", version='%prog ' + __version__)
|
||||||
|
|
||||||
parser.add_option("-c", "--cfg", dest="config", default="test",
|
parser.add_option("-c", "--config", "--cfg", dest="config", default="test",
|
||||||
help="name of the config file with the Name of the rows to be used.",
|
help="name of the config file in cfg/ with the lines to be written",
|
||||||
metavar="CONFIG_FILE")
|
metavar="CONFIG_FILE")
|
||||||
parser.add_option("-i", "--infile", dest="infile",
|
parser.add_option("-i", "--infile", dest="infile",
|
||||||
help="csv file with input of names/content",
|
help="csv file with input of names/content",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-s", "--startfrom", dest="startfrom",
|
parser.add_option("-s", "--startfrom", dest="startfrom",
|
||||||
help="csv file with input of names/content",
|
help="start the numbering again at every word / capital letter",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_option("-o", "--outdir", dest="outdir", default=os.path.expandvars('$PICCREATE_OUT'),
|
parser.add_option("-o", "--outdir", dest="outdir", default=os.path.expandvars('$PICCREATE_OUT'),
|
||||||
help="path to the directory where the maps will be generated",
|
help="directory where the pictures will be written. default is $PICCREATE_OUT",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-y", "--dry", dest="dry",
|
parser.add_option("-y", "--dry", dest="dry",
|
||||||
help="dont generate images. Just ask the coordinates and fill database.", action='store_true' )
|
help="dont write files, print the svg instead", action='store_true' )
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|||||||
+21
-14
@@ -123,16 +123,14 @@ def main():
|
|||||||
print('ImageMagick not found. Please install it (https://imagemagick.org).')
|
print('ImageMagick not found. Please install it (https://imagemagick.org).')
|
||||||
return None
|
return None
|
||||||
#set the workpath and the default config
|
#set the workpath and the default config
|
||||||
work_path = os.path.expandvars('$PICCREATE_OUT')
|
work_path = os.path.expandvars(options.outdir)
|
||||||
if options.svgfolder:
|
|
||||||
work_path = os.path.expandvars(options.svgfolder)
|
|
||||||
if not os.path.exists(work_path):
|
if not os.path.exists(work_path):
|
||||||
print('\"'+ work_path +'\" does not exist. Please give the name of the folder with the svg-files!')
|
print('\"'+ work_path +'\" does not exist. Please give the name of the folder with the svg-files!')
|
||||||
return None
|
return None
|
||||||
pic_config = {
|
pic_config = {
|
||||||
'width' : '600',
|
'width' : '600',
|
||||||
'height' : '200',
|
'height' : '200',
|
||||||
'format' : options.format,
|
'format' : options.format or 'jpg',
|
||||||
'density' : '150',
|
'density' : '150',
|
||||||
'background' : 'white',
|
'background' : 'white',
|
||||||
'folder' : work_path,
|
'folder' : work_path,
|
||||||
@@ -162,7 +160,12 @@ def main():
|
|||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
config.read(config_path, encoding='utf-8')
|
config.read(config_path, encoding='utf-8')
|
||||||
# fill the config
|
# fill the config
|
||||||
pic_config = dict(config.items(options.format))
|
if not config.has_section(options.section):
|
||||||
|
print('section [' + options.section + '] is missing in ' + config_path)
|
||||||
|
return None
|
||||||
|
pic_config = dict(config.items(options.section))
|
||||||
|
if options.format:
|
||||||
|
pic_config['format'] = options.format
|
||||||
if options.background:
|
if options.background:
|
||||||
pic_config['background'] = options.background
|
pic_config['background'] = options.background
|
||||||
elif 'background' in pic_config:
|
elif 'background' in pic_config:
|
||||||
@@ -221,14 +224,17 @@ Read Confg, create wakeup and scale this kind of jiffy box
|
|||||||
parser.add_option("-b", "--background", dest="background",
|
parser.add_option("-b", "--background", dest="background",
|
||||||
help="set the backgroundcolor. 'none' for transparent",
|
help="set the backgroundcolor. 'none' for transparent",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-c", "--config", dest="config",
|
parser.add_option("-c", "--config", "--cfg", dest="config",
|
||||||
help="config file with all data for jobs",
|
help="config file in cfg/ with the picture sizes",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-f", "--force", dest="force", default=False,
|
parser.add_option("-f", "--force", dest="force", default=False,
|
||||||
help="create the pictures, no matter if they alreads exist",
|
help="create the pictures, no matter if they already exist",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_option("--format", dest="format", default='jpg',
|
parser.add_option("--section", dest="section", default='png',
|
||||||
help="format of the picture",
|
help="section in the config file. default is png",
|
||||||
|
action='store')
|
||||||
|
parser.add_option("--format", dest="format",
|
||||||
|
help="jpg or png, overrides the config",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-i", "--infile", dest="infile",
|
parser.add_option("-i", "--infile", dest="infile",
|
||||||
help="csv file with input of names/content",
|
help="csv file with input of names/content",
|
||||||
@@ -239,8 +245,10 @@ Read Confg, create wakeup and scale this kind of jiffy box
|
|||||||
parser.add_option("-p", "--progress", dest="progress",
|
parser.add_option("-p", "--progress", dest="progress",
|
||||||
help="print a progression bar",
|
help="print a progression bar",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_option("-s", "--svgfolder", dest="svgfolder",
|
parser.add_option("-o", "--outdir", "--svgfolder", dest="outdir",
|
||||||
help="path to the folder with the svg-files",
|
default=os.path.expandvars('$PICCREATE_OUT'),
|
||||||
|
help="folder with the svg files, the pictures are written there too. "
|
||||||
|
"default is $PICCREATE_OUT",
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option("-t", "--test", dest="test",
|
parser.add_option("-t", "--test", dest="test",
|
||||||
help="number of default svg-files that will be created and tested",
|
help="number of default svg-files that will be created and tested",
|
||||||
@@ -249,8 +257,7 @@ Read Confg, create wakeup and scale this kind of jiffy box
|
|||||||
help="print the status of the conversion",
|
help="print the status of the conversion",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_option("-y", "--dry", dest="dry",
|
parser.add_option("-y", "--dry", dest="dry",
|
||||||
help="dont generate images. \
|
help="dont generate images, just try if the conversion would succeed",
|
||||||
just try if the conversion would success",
|
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|||||||
+3
-3
@@ -235,7 +235,7 @@ Screenshots of all urls in in/kunden.csv (lines: customerid;url):
|
|||||||
$ %prog -c webscan -i kunden
|
$ %prog -c webscan -i kunden
|
||||||
""", version='%prog ' + __version__)
|
""", version='%prog ' + __version__)
|
||||||
|
|
||||||
parser.add_option("-c", "--cfg", dest="config", default="webscan",
|
parser.add_option("-c", "--config", "--cfg", dest="config", default="webscan",
|
||||||
help="config file with a [webscan] section (width, height, format)",
|
help="config file with a [webscan] section (width, height, format)",
|
||||||
metavar="CONFIG_FILE")
|
metavar="CONFIG_FILE")
|
||||||
parser.add_option("--section", dest="section", default="webscan",
|
parser.add_option("--section", dest="section", default="webscan",
|
||||||
@@ -248,11 +248,11 @@ Screenshots of all urls in in/kunden.csv (lines: customerid;url):
|
|||||||
help="jpg or png, overrides the config")
|
help="jpg or png, overrides the config")
|
||||||
parser.add_option("-j", "--jobs", dest="jobs", default=4,
|
parser.add_option("-j", "--jobs", dest="jobs", default=4,
|
||||||
help="number of pages loaded in parallel. default is 4")
|
help="number of pages loaded in parallel. default is 4")
|
||||||
parser.add_option("-t", "--timeout", dest="timeout", default=20,
|
parser.add_option("--timeout", dest="timeout", default=20,
|
||||||
help="seconds to wait for a page. default is 20")
|
help="seconds to wait for a page. default is 20")
|
||||||
parser.add_option("-f", "--force", dest="force", action='store_true',
|
parser.add_option("-f", "--force", dest="force", action='store_true',
|
||||||
help="create the pictures, no matter if they already exist")
|
help="create the pictures, no matter if they already exist")
|
||||||
parser.add_option("-b", "--browser", dest="browser",
|
parser.add_option("--browser", dest="browser",
|
||||||
default=os.environ.get('PICCREATE_BROWSER'),
|
default=os.environ.get('PICCREATE_BROWSER'),
|
||||||
help="path to a chromium executable instead of the playwright one "
|
help="path to a chromium executable instead of the playwright one "
|
||||||
"(default: $PICCREATE_BROWSER)")
|
"(default: $PICCREATE_BROWSER)")
|
||||||
|
|||||||
Reference in New Issue
Block a user