algoo / preview-generator

generates previews of files with cache management
https://pypi.org/project/preview-generator/
MIT License
224 stars 49 forks source link

Bug: Inkscape builder broken with inkscape 1.0+ #263

Closed inkhey closed 2 years ago

inkhey commented 2 years ago

Description and expectations

Inkscape 1.0+ has changed the command line options, which broke preview generation with it. Inkscape 1.0+ is shipped with debian bullseye and is in debian buster backport.

Version information

Extra information

Current code:

https://github.com/algoo/preview-generator/blob/a68256816f6953269d2ca710a0ee72a9e5bdb94a/preview_generator/preview/builder/image__inkscape.py#L60

Inkscape command line help (ubuntu 18.04)

$ inkscape --version
Gtk-Message: 10:50:42.162: Failed to load module "canberra-gtk-module"
Inkscape 0.92.3 (2405546, 2018-03-11)
$ inkscape --help
Gtk-Message: 10:50:56.416: Failed to load module "canberra-gtk-module"
Utilisation: inkscape [OPTIONS...] [FICHIER...]

Options disponibles :
  -V, --version                               Afficher la version d'Inkscape
  -z, --without-gui                           Ne pas utiliser le serveur X
                                              (traiter les fichiers seulement
                                              depuis la console)
  -g, --with-gui                              Essayer d'utiliser le serveur X
                                              (même si $DISPLAY n'est pas
                                              défini)
  -f, --file=NOM_DE_FICHIER                   Ouvrir les document(s)
                                              spécifiés (la chaîne d'option
                                              peut être exclue)
  -p, --print=NOM_DE_FICHIER                  Imprimer les document(s) dans le
                                              fichier de sortie spécifié
                                              (utilisez '| programme ' pour
                                              envoyer la sortie à un
                                              programme)
  -e, --export-png=NOM_DE_FICHIER             Exporter le document vers un
                                              fichier PNG
  -d, --export-dpi=PPP                        Résolution pour l'exportation
                                              en matriciel et la
                                              rastérisation des filtres en
                                              PS/EPS/PDS (96 par défaut)
  -a, --export-area=x0:y0:x1:y1               Zone à exporter, en unités
                                              utilisateur SVG (par défaut, la
                                              zone de travail entière ; 0,0
                                              est le coin inférieur gauche)
  -D, --export-area-drawing                   La zone à exporter est le
                                              dessin entier (pas la zone de
                                              travail)
  -C, --export-area-page                      La zone à exporter est la zone
                                              de travail entière
      --export-margin=VALEUR                  Définit la marge autour de la
                                              zone exportée (0 par défaut)
                                              en unités de la taille de la
                                              page pour le SVG ou en mm pour
                                              PS/EPS/PDF.
      --export-area-snap                      Ajuster la zone à exporter en
                                              image matricielle aux valeurs
                                              entières supérieures les plus
                                              proches (en unités utilisateur
                                              SVG)
  -w, --export-width=LARGEUR                  La largeur en pixels de l'image
                                              matricielle exportée (préempte
                                              export-dpi)
  -h, --export-height=HAUTEUR                 La hauteur en pixels de l'image
                                              matricielle exportée (préempte
                                              export-dpi)
  -i, --export-id=ID                          L'ID de l'objet à exporter
  -j, --export-id-only                        N'exporter que l'objet avec
                                              export-id, cacher tous les
                                              autres (seulement avec export-id)
  -t, --export-use-hints                      Utiliser le nom de fichier et la
                                              résolution enregistrés lors de
                                              l'exportation (seulement avec
                                              export-id)
  -b, --export-background=COULEUR             Couleur de fond de l'image
                                              matricielle exportée (dans un
                                              format accepté par le SVG)
  -y, --export-background-opacity=VALEUR      Opacité du fond de l'image
                                              matricielle exportée (soit
                                              entre 0,0 et 1,0 soit entre 1 et
                                              255)
  -l, --export-plain-svg=NOM_DE_FICHIER       Exporter le document en SVG
                                              simple (sans espace de nom de
                                              Sodipodi ou d'Inkscape)
  -P, --export-ps=NOM_DE_FICHIER              Exporter le document en fichier
                                              PS
  -E, --export-eps=NOM_DE_FICHIER             Exporter le document en fichier
                                              EPS
      --export-ps-level=Niveau PostScript     Niveau PostScript utilisé pour
                                              l'exportation. Les choix
                                              possibles sont 2 (par défaut)
                                              et 3.
  -A, --export-pdf=NOM_DE_FICHIER             Exporter le document en fichier
                                              PDF
      --export-pdf-version=VERSION_PDF        Exporter le PDF dans une version
                                              donnée (astuce : assurez-vous
                                              que la valeur saisie corresponde
                                              bien à la chaîne présentée
                                              dans la boîte de dialogue
                                              d'exportation PDF, par exemple
                                              « PDF 1.4 » — conforme
                                              PDF-a)
      --export-latex                          Exporte en PDF, PS ou EPS sans
                                              texte, celui-ci étant exporté
                                              dans un LaTeX séparé. Le
                                              résultat peut être intégré
                                              dans LaTeX avec :
                                              \input{latexfile.tex}
  -M, --export-emf=NOM_DE_FICHIER             Exporter le document en fichier
                                              EMF (Métafichier amélioré)
  -m, --export-wmf=NOM_DE_FICHIER             Exporter le document en fichier
                                              WMF (Métafichier Windows)
  -T, --export-text-to-path                   Convertir les objets texte en
                                              chemins lors de l'export (PS,
                                              EPS, PDF, SVG)
      --export-ignore-filters                 Les objets filtrés sont rendus
                                              sans filtres, plutôt que
                                              rastérisés (PS, EPS, PDF)
  -X, --query-x                               Demander l'abscisse (coordonnée
                                              X) du dessin ou, si spécifié
                                              avec --query-id, de l'objet
  -Y, --query-y                               Demander l'ordonnée
                                              (coordonnée Y) du dessin ou, si
                                              spécifié avec --query-id, de
                                              l'objet
  -W, --query-width                           Demander la largeur du dessin
                                              ou, si spécifié avec
                                              --query-id, de l'objet
  -H, --query-height                          Demander la hauteur du dessin
                                              ou, si spécifié avec
                                              --query-id, de l'objet
  -S, --query-all                             Afficher id,x,y,w,h pour tous
                                              les objets
  -I, --query-id=ID                           L'ID de l'objet dont les
                                              dimensions sont demandées
  -x, --extension-directory                   Lister le dossier d'extensions,
                                              puis sortir
      --vacuum-defs                           Supprimer les éléments
                                              inutiles des section(s) defs du
                                              document
      --dbus-listen                           Saisissez une boucle d'écoute
                                              pour les messages D-Bus en mode
                                              console
      --dbus-name=NOM_DE_BUS                  Spécifie le nom du bus D-Bus
                                              sur lequel écouter les messages
                                              (org.inkscape par défaut)
      --verb-list                             Afficher les IDs de tous les
                                              verbes d'Inkscape
      --verb=ID_ACTION                        Verbe sélectionné au
                                              démarrage d'Inkscape.
      --select=ID_OBJET                       ID de l'objet à sélectionner
                                              au démarrage d'Inkscape.
      --shell                                 Démarrer Inkscape en mode ligne
                                              de commande interactif.
      --no-convert-text-baseline-spacing      Ne pas corriger l'espacement des
                                              lignes de base à l'ouverture de
                                              fichiers hérités (pré-0.92).
      --convert-dpi-method=[...]              Méthode utilisée pour
                                              convertir la résolution des
                                              documents pré-0.92, si
                                              nécessaire.
                                              ([none|scale-viewbox|scale-document])

Options d'aide :
  -?, --help                                  Montre ce message d'aide
      --usage                                 Affiche un bref descriptif de
                                              l'utilisation

Inkscape command line help (debian bullseye docker)

inkscape --version
Unable to init server: Could not connect: Connection refused
Inkscape 1.0.2 (e86c870879, 2021-01-15)
    Pango version: 1.46.2
inkscape --help
Unable to init server: Could not connect: Connection refused
Usage:
  inkscape [OPTION?] file1 [file2 [fileN]]

Process (or open) one or more files.

Help Options:
  -?, --help                                 Show help options
  --help-all                                 Show all help options
  --help-gapplication                        Show GApplication options

Application Options:
  -V, --version                              Print Inkscape version
  --system-data-directory                    Print system data directory
  --user-data-directory                      Print user data directory

File import:                        
  -p, --pipe                                 Read input file from standard input (stdin)
  --pdf-page=PAGE                            PDF page number to import
  --pdf-poppler                              Use poppler when importing via commandline
  --convert-dpi-method=[...]                 Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document]
  --no-convert-text-baseline-spacing         Do not fix pre-0.92 document's text baseline spacing on opening

File export:                        
  -o, --export-filename=EXPORT-FILENAME      Output file name (file type is guessed from extension)
  --export-overwrite                         Overwrite input file
  --export-type=[...]                        File type(s) to export: [svg,png,ps,eps,pdf,emf,wmf,xaml]

Export geometry:                    
  -C, --export-area-page                     Area to export is page
  -D, --export-area-drawing                  Area to export is whole drawing (ignoring page size)
  -a, --export-area=x0:y0:x1:y1              Area to export in SVG user units
  --export-area-snap                         Snap the bitmap export area outwards to the nearest integer values
  -d, --export-dpi=DPI                       Resolution for bitmaps and rasterized filters; default is 96
  -w, --export-width=WIDTH                   Bitmap width in pixels (overrides --export-dpi)
  -h, --export-height=HEIGHT                 Bitmap height in pixels (overrides --export-dpi)
  --export-margin=MARGIN                     Margin around export area: units of page size for SVG, mm for PS/EPS/PDF

Export options:                     
  -i, --export-id=OBJECT-ID[;OBJECT-ID]*     ID(s) of object(s) to export
  -j, --export-id-only                       Hide all objects except object with ID selected by export-id
  -l, --export-plain-svg                     Remove Inkscape-specific SVG attributes/properties
  --export-ps-level=PS-Level                 Postscript level (2 or 3); default is 3
  --export-pdf-version=PDF-VERSION           PDF version (1.4 or 1.5)
  -T, --export-text-to-path                  Convert text to paths (PS/EPS/PDF/SVG)
  --export-latex                             Export text separately to LaTeX file (PS/EPS/PDF)
  --export-ignore-filters                    Render objects without filters instead of rasterizing (PS/EPS/PDF)
  -t, --export-use-hints                     Use stored filename and DPI hints when exporting object selected by --export-id
  -b, --export-background=COLOR              Background color for exported bitmaps (any SVG color string)
  -y, --export-background-opacity=VALUE      Background opacity for exported bitmaps (0.0 to 1.0, or 1 to 255)

Query object/document geometry:     
  -I, --query-id=OBJECT-ID[,OBJECT-ID]*      ID(s) of object(s) to be queried
  -S, --query-all                            Print bounding boxes of all objects
  -X, --query-x                              X coordinate of drawing or object (if specified by --query-id)
  -Y, --query-y                              Y coordinate of drawing or object (if specified by --query-id)
  -W, --query-width                          Width of drawing or object (if specified by --query-id)
  -H, --query-height                         Height of drawing or object (if specified by --query-id)

Advanced file processing:           
  --vacuum-defs                              Remove unused definitions from the <defs> section(s) of document
  --select=OBJECT-ID[,OBJECT-ID]*            Select objects: comma-separated list of IDs

  --actions=ACTION(:ARG)[;ACTION(:ARG)]*     List of actions (with optional arguments) to execute
  --action-list                              List all available actions

  --verb=VERB[;VERB]*                        List of verbs to execute
  --verb-list                                List all available verbs

Interface:                          
  -g, --with-gui                             With graphical user interface (required by some actions/verbs)
  --batch-process                            Close GUI after executing all actions/verbs

  --shell                                    Start Inkscape in interactive shell mode

D-Bus:                              
  --dbus-listen                              Enter a listening loop for D-Bus messages in console mode
  --dbus-name=BUS-NAME                       Specify the D-Bus name; default is 'org.inkscape'

Examples:
  Export input SVG (in.svg) to PDF (out.pdf) format:
    inkscape --export-filename=out.pdf in.svg
  Export input files (in1.svg, in2.svg) to PNG format keeping original name (in1.png, in2.png):
    inkscape --export-type=png in1.svg in2.svg
  See 'man inkscape' and http://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line for more details.

Launch inkscape --version when the inkscape builder is loaded and use this information to decide which arguments the builder will use for generating previews.

inkhey commented 2 years ago

fixed by #264