#1 Le 20/05/2007, à 17:00
- guil
shell: construction d'une commande convert
Salut,
j'ai une partie d'un script qui en gros fait ca:
#!/bin/sh
text="foo bar"
coord="+0+0"
annotate="-annotate $coord '$text'"
convert +antialias \
-size 720x576 xc:'rgba(0,0,0,255)' \
-undercolor 'rgba(0,0,0,128)' \
-fill 'rgba(255,255,255,0)' \
-stroke 'rgba(254,254,254)' \
-gravity Center -pointsize 40 \
$annotate buttons.png
je n'arrive pas à comprendre le résultat, il essaie d'ouvrir le fichier image "bar'" pour y écrire "'foo", alors que taper directement dans un terminal la commande crée bien une image "buttons.png" avec "foo bar" comme texte.
mon script doit contenir une erreur stupide avec les ' et " mais je n'arrive pas à mettre le doigt dessus.
Hors ligne
#2 Le 20/05/2007, à 21:34
- abetsic
Re : shell: construction d'une commande convert
Bonjour,
j'ai modifié un peu ton script et j'ai réussi à le faire fonctionner :
#!/bin/sh
text="foo bar"
coord="+0+0"
annotate="-annotate $coord"
convert +antialias \
-size 720x576 xc:'rgba(0,0,0,255)' \
-undercolor 'rgba(0,0,0,128)' \
-fill 'rgba(255,255,255,0)' \
-stroke 'rgba(254,254,254)' \
-gravity Center -pointsize 40 \
$annotate "$text" buttons.png
Hors ligne
#3 Le 22/05/2007, à 10:58
- guil
Re : shell: construction d'une commande convert
salut,
merci mais en fait il y a plusieurs -annotate à passer au convert, le $annotate est construit dans une boucle avec
annotate="$annotate -annotate $coord '$text'"
j'ai contourné le pb en faisant le convert dans la boucle de cette façon
convert +antialias \
-size 720x576 xc:'rgba(0,0,0,255)' \
-undercolor 'rgba(0,0,0,128)' \
-fill 'rgba(255,255,255,0)' \
-stroke 'rgba(254,254,254)' \
-gravity Center -pointsize 40 \
-annotate $coord "$text" buttons.png buttons.png
ca marche mais j'aimerai bien comprendre ce qui cloche dans la première méthode.
Hors ligne