informatique:imagemagick
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
informatique:imagemagick [2016/03/05 14:09] – [Convertir en polaroïd] alexis | informatique:imagemagick [2022/09/18 10:36] (Version actuelle) – [Supprimer les données EXIF d'une image] alexis | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== ImageMagick ====== | ====== ImageMagick ====== | ||
- | Pour toutes les manipulations, | + | |
+ | |||
+ | ===== Modification d' | ||
+ | |||
+ | Sauf indication contraire, pour toutes les manipulations, | ||
{{: | {{: | ||
+ | {{: | ||
+ | |||
- | ===== Redimensionner une image en conservant le ratio original | + | ==== Redimensionner une image en conservant le ratio original ==== |
Utile, si on ne connait pas l' | Utile, si on ne connait pas l' | ||
+ | <WRAP prewrap> | ||
< | < | ||
mogrify -geometry 100x100 climbing.jpg | mogrify -geometry 100x100 climbing.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Afficher les caractéristiques d'une image ===== | + | |
- | <code> | + | ==== Générer |
- | identify climbing.jpg | + | <WRAP prewrap> |
- | </ | + | |
- | Résultat : | + | |
- | < | + | |
- | climbing.jpg JPEG 300x200 300x200+0+0 8-bit DirectClass 18.8KB 0.000u 0:00.000 | + | |
- | </ | + | |
- | ===== Générer une mosaïque ===== | + | |
< | < | ||
montage -tile 3x1 -background transparent -geometry +0+0 climbing.jpg climbing.jpg climbing.jpg tile.jpg | montage -tile 3x1 -background transparent -geometry +0+0 climbing.jpg climbing.jpg climbing.jpg tile.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Créer une image dont les dimensions sont fixées en utilisant un maximum de l' | + | |
+ | ==== Créer une image dont les dimensions sont fixées en utilisant un maximum de l' | ||
+ | <WRAP prewrap> | ||
< | < | ||
convert climbing.jpg -resize 50x100^ -gravity center -extent 50x100 climbing-50x100.jpg | convert climbing.jpg -resize 50x100^ -gravity center -extent 50x100 climbing-50x100.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Convertir le résultat d'une commande ===== | ||
- | < | ||
- | convert -border 15x15 -bordercolor "# | ||
- | </ | ||
- | Résultat :\\ | ||
- | {{: | ||
- | ===== Extraire une partie de l' | + | ==== Extraire une partie de l' |
+ | <WRAP prewrap> | ||
< | < | ||
convert climbing.jpg -crop 200x100+50+50 crop.jpg | convert climbing.jpg -crop 200x100+50+50 crop.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Ajouter une bordure ===== | + | ==== Ajouter une bordure ==== |
+ | <WRAP prewrap> | ||
< | < | ||
convert climbing.jpg -bordercolor violet -border 10x10 border.jpg | convert climbing.jpg -bordercolor violet -border 10x10 border.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Convertir en polaroïd ===== | + | ==== Convertir en polaroïd ==== |
+ | <WRAP prewrap> | ||
< | < | ||
convert climbing.jpg -thumbnail 200x200 -bordercolor white -background black +polaroid polaroid.jpg | convert climbing.jpg -thumbnail 200x200 -bordercolor white -background black +polaroid polaroid.jpg | ||
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
- | ===== Découper une image ===== | + | ==== Découper une image pour faire une mosaïque |
+ | <WRAP prewrap> | ||
< | < | ||
- | convert -crop 3x2@ climbing.jpg | + | convert |
</ | </ | ||
+ | </ | ||
Résultat :\\ | Résultat :\\ | ||
{{: | {{: | ||
Ligne 69: | Ligne 77: | ||
{{: | {{: | ||
{{: | {{: | ||
- | ===== Pour aller plus loin ===== | + | <WRAP tip> |
+ | '' | ||
+ | </ | ||
+ | <WRAP info> | ||
+ | Il est possible de d' | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert climbing.jpg -crop 3x2-40-40@ -set filename: | ||
+ | </ | ||
+ | </ | ||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | ==== Appliquer une symétrie ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | # Applique une symétrie verticale | ||
+ | convert climbing.jpg -flip vertical.flip.jpg | ||
+ | |||
+ | # Applique une symétrie horizontale | ||
+ | convert climbing.jpg -flop horizontal.flip.jpg | ||
+ | </ | ||
+ | </ | ||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | <WRAP info> | ||
+ | Il est possible d' | ||
+ | |||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Ré-orienter une image ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | # Cré une nouvelle image | ||
+ | convert -rotate 90 climbing.jpg rotate.jpg | ||
+ | |||
+ | # Modifie l' | ||
+ | mogrify -rotate 90 climbing.jpg | ||
+ | </ | ||
+ | </ | ||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | <WRAP tip> | ||
+ | Pour effectuer plusieurs actions modifiant la taille de l' | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert climbing.jpg -background Black -rotate 45 +repage -gravity Center -crop 200x200+0+0 rotate.crop.jpg | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | Sans '' | ||
+ | {{: | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | Avec '' | ||
+ | {{: | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Ajouter un masque circulaire ==== | ||
+ | |||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert climbing.jpg -gravity Center \( -size 200x200 xc:Black -fill White -draw ' | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP tip> | ||
+ | Dans le cas où il y a de nombreuses images à manipuler, il est recommandé de créer le masque dans un fichier externe et de l' | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | # Génération du masque | ||
+ | convert -size 200x200 xc:Black -fill White -draw ' | ||
+ | |||
+ | # Application du masque | ||
+ | convert climbing.jpg -gravity Center mask.png -compose CopyOpacity -composite -background Black -alpha remove circle.mask.jpg | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | |||
+ | ==== Fusionner des images ==== | ||
+ | |||
+ | Pour fusionner des images, il faut qu' | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | # Ajout de la transparence aux images | ||
+ | convert climbing.jpg -fill none -draw "alpha 0,0 point" -channel alpha -evaluate Divide 2 temp1.png | ||
+ | convert knot.jpg -fill none -draw "alpha 0,0 point" -channel alpha -evaluate Divide 2 temp2.png | ||
+ | |||
+ | # Superposition des images | ||
+ | composite temp1.png temp2.png composite.default.png | ||
+ | </ | ||
+ | </ | ||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | |||
+ | <WRAP info> | ||
+ | Si le mode de composition par défaut ne donne pas un résultat satisfaisant, | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Créer une image animée ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert -delay 5 -loop climbing.*.jpg climbing.gif | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Résultat :\\ | ||
+ | {{: | ||
+ | |||
+ | ==== Supprimer le canal alpha ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | mogrify -background white -alpha remove *.png | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Dessiner sur une image ==== | ||
+ | Pour mettre à jour la page [[jeux: | ||
+ | |||
+ | Je me suis servi des documents suivants pour produire les images ci-dessous : | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | {{ jeux: | ||
+ | {{ jeux: | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | convert chicago.original.jpg -pointsize 20 -draw 'fill black rectangle 258,73 282,102 fill white rectangle 260,75 280,100 fill black text 265,95 " | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | {{ jeux: | ||
+ | {{ jeux: | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | convert havana.original.jpg -pointsize 20 -draw 'fill black rectangle 90,400 114,429 fill white rectangle 92,402 112,427 fill black text 97,422 " | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | {{ jeux: | ||
+ | {{ jeux: | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | convert vegas.original.jpg -pointsize 20 -draw 'fill black rectangle 446,1163 470,1192 fill white rectangle 448,1165 468,1190 fill black text 453,1185 " | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | {{ jeux: | ||
+ | {{ jeux: | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | convert rio.original.jpg -pointsize 20 -draw 'fill black rectangle 353,94 377,123 fill white rectangle 355,96 375,121 fill black text 360,116 " | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Pour aller plus loin ==== | ||
* [[http:// | * [[http:// | ||
+ | |||
+ | ===== Autre ===== | ||
+ | |||
+ | ==== Afficher les caractéristiques d'une image ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | identify climbing.jpg | ||
+ | </ | ||
+ | </ | ||
+ | Résultat : | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | climbing.jpg JPEG 300x200 300x200+0+0 8-bit DirectClass 18.8KB 0.000u 0:00.000 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Écrire dans une image ==== | ||
+ | **Le résultat d'une commande** | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert -border 15x15 -bordercolor "# | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **Le contenu d'un fichier** | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert -fill '# | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **Du texte positionné** | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | convert -size 200x30 xc: | ||
+ | </ | ||
+ | </ | ||
+ | ==== Générer un fichier PDF vide ==== | ||
+ | |||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | convert xc:none -page A4 a.pdf | ||
+ | </ | ||
+ | </ | ||
+ | Astuce trouvée [[http:// | ||
+ | <WRAP important> | ||
+ | Si la commande retourne l' | ||
+ | Pour cela, il faut modifier le fichier ''/ | ||
+ | <WRAP prewrap> | ||
+ | <code xml> | ||
+ | <!-- Avant : politique de sécurité appliquée aux fichiers PDF, aucune action autorisée --> | ||
+ | <policy domain=" | ||
+ | |||
+ | <!-- Après : politique de sécurité appliquée aux fichiers PDF, lecture et écriture autorisée --> | ||
+ | <policy domain=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Supprimer les données EXIF d'une image ==== | ||
+ | <WRAP prewrap> | ||
+ | < | ||
+ | mogrify -strip climbing.jpg | ||
+ | </ | ||
+ | </ |
informatique/imagemagick.1457215764.txt.gz · Dernière modification : 2016/03/05 14:09 de alexis