logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).


L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT → ODT PDF Export

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
utilisateurs:slyfox:scripts:slyexif [16/06/2017 23:24]
Slyfox [Script]
— (Version actuelle)
Ligne 1: Ligne 1:
-====== SlyExif ====== 
  
-  * Niveau requis :  {{tag>​débutant avisé}} 
-  * Commentaires : //Version en test. // 
-  * Débutant, à savoir : [[:​doc:​systeme:​commandes:​le_debianiste_qui_papillonne|Utiliser GNU/Linux en ligne de commande, tout commence là !.]] :-) 
- 
-===== Introduction ===== 
- 
-SlyExif est une mini interface graphique basé sur exiftool, il 2 fonctions: 
- 
-  * Éditer la date de création de l'​image jpeg/​jpg/​png. 
-  * Supprimer en masse les métadonnées avec possibilité de conserver la date de création. 
- 
-===== Installation ===== 
- 
-Pour fonctionner SlyExif a besoin de 2 paquets: yad, libimage-exiftool-perl et ffmpeg 
- 
-<code root>​apt-get update</​code>​ 
-<code root>​apt-get install yad libimage-exiftool-perl ffmpeg</​code>​ 
- 
-Ensuite il suffit de créer un fichier vierge, le nommer "​SlyExif"​ et de copier/​coller le script ci-dessous.\\ 
- 
-N'​oublions pas de rendre exécutable "​SlyExif",​ pour ce faire clic droit sur le fichier "​SlyExif"​ --> "​Propriétés"​ --> Onglet "​Permissions"​ et cochons "​Autoriser l’exécution du fichier comme un programme"​. 
- 
-===== Utilisation ===== 
- 
-Il suffit de faire un double clic sur le fichier "​SlyExif"​ et choisir <​key>​Lancer dans un Terminal</​key>​ ou <​key>​Lancer</​key>​.\\ 
- 
- 
-===== Script ===== 
- 
-<file SlyExif.sh>​ 
-#! /bin/bash 
-  
-# Auteur: Slyfox 
-# Date dernière version: 16 juin 2017 23h20 
-# Dépendence:​ yad, libimage-exiftool-perl,​ ffmpeg 
-  
-#​======================================================================================================================================= 
-# Script qui supprime les métadonnées des images jpg/​jpeg/​png. ​ 
-# Edition de la date de création des images. 
-# (version en test) 
-#​======================================================================================================================================= 
-YADMENU() 
-{ 
-yadMenu=$(yad --list --radiolist \ 
---title "​SlyExif"​ \ 
---width="​300"​ \ 
---height="​200"​ \ 
---print-column="​2"​ \ 
---hide-column="​2"​ \ 
---button="​gtk-quit:​1"​ \ 
---button="​gtk-ok:​0"​ \ 
---column=""​ --column=""​ --column=""​ \ 
-"​TRUE"​ "​1"​ "​Editer date de création de l'​image"​ \ 
-"​FALSE"​ "​2"​ "​Supprimer métadonnées"​ | awk -F [\|] '​{print $1}') 
-  
-yadID="​$?"​ 
-  
-# Navigation 
-if [[ "​${yadMenu}"​ -eq "​1"​ ]]; then 
- YADFICHIER 
-  
-elif [[ "​${yadMenu}"​ -eq "​2"​ ]]; then 
- YADFICHIERMULTIPLE  
-  
-elif [[ $yadID -eq "​1"​ ]]; then 
- exit 
-  
-elif [[ $yadID -eq "​252"​ ]]; then 
- exit 
-  
-fi 
-} 
-#​======================================================================================================================================= 
-function YADFICHIER() 
-{ 
-cheminImage=$(yad --file \ 
---title "​SlyExif"​ \ 
---width="​700"​ \ 
---height="​500"​ \ 
---separator="​\n"​ \ 
---center \ 
---filename="​${cheminDossier}"​ \ 
---file-filter="​Images (jpg - jpeg - png)| *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG" \ 
---file-filter "Tous | *" \ 
---add-preview \ 
---button="​Menu:​1"​ \ 
---button="​Suivant:​0"​) 
-  
-yadID="​$?"​ 
-  
-# Navigation 
-if [[ $yadID -eq "​0"​ ]]; then 
- YADEDIT 
-  
-elif [[ $yadID -eq "​1"​ ]]; then 
- YADMENU 
-  
-elif [[ $yadID -eq "​252"​ ]]; then 
- exit 
-  
-fi 
-} 
-#​======================================================================================================================================= 
-function YADEDIT() 
-{ 
-warning=""​ 
-  
-# Redimensionnement image pour aperçu 
-ffmpeg -y -i "​${cheminImage}"​ -vf scale=200:​-1 "​$HOME/​.slyexif/​image_tmp.jpeg"​ 
-  
-dateTimeOriginal=$(exiftool "​${cheminImage}"​ | awk '/​Date\/​Time Original/ {print $4}' | awk 'NR==1 {print $0}') 
-  
-if [[ -z "​${dateTimeOriginal}"​ ]]; then 
- dateTimeOriginal=$(date '​+%Y:​%m:​%d'​) 
- warning=(Avertissement\ la\ date\ et\ l\'​heure\ réelles\ de\ l\'​image\ n\'​ont\ pas\ pu\ être\ trouvées.!gtk-dialog-warning) 
-fi 
-  
-heureTimeOriginal=$(exiftool "​${cheminImage}"​ | awk '/​Date\/​Time Original/ {print $5}' | awk 'NR==1 {print $0}') 
-  
-if [[ -z "​${heureTimeOriginal}"​ ]]; then 
- heureTimeOriginal=$(date '​+%H:​%M:​%S'​) 
-fi 
-  
-yadDate=$( 
-yad --form \ 
---title "​SlyExif"​ \ 
---width="​700"​ \ 
---height="​200"​ \ 
---image="​$HOME/​.slyexif/​image_tmp.jpeg"​ \ 
---date-format="​%Y:​%m:​%d"​ \ 
---columns 1 \ 
---field="​ ":LBL ""​ \ 
---field="<​span foreground='​black'><​b>​Chemin fichier image: </​b></​span>":​LBL " " \ 
---field="​${cheminImage}":​LBL "​${cheminImage}"​ \ 
---field="​ ":LBL ""​ \ 
---field="<​span foreground='​black'><​b>​Date création image: </​b></​span>":​LBL " " \ 
---field="​ ":DT "​${dateTimeOriginal}"​ \ 
---field="​ ":LBL ""​ \ 
---field="<​span foreground='​black'><​b>​Heure création image: </​b></​span>":​LBL " " \ 
---field="​ ":CBE "​${heureTimeOriginal}!00:​00:​00!00:​30:​00!01:​00:​00!01:​30:​00!02:​00:​00!02:​30:​00!03:​00:​00!03:​30:​00!04:​00:​00!04:​30:​00!05:​00:​00!05:​30:​00!06:​00:​00!06:​30:​00!07:​00:​00!07:​30:​00!08:​00:​00!08:​30:​00!09:​00:​00!09:​30:​00!10:​00:​00!10:​30:​00!11:​00:​00!11:​30:​00!12:​00:​00!12:​30:​00!13:​00:​00!13:​30:​00!14:​00:​00!14:​30:​00!15:​00:​00!15:​30:​00!16:​00:​00!16:​30:​00!17:​00:​00!17:​30:​00!18:​00:​00!18:​30:​00!19:​00:​00!19:​30:​00!20:​00:​00!20:​30:​00!21:​00:​00!21:​30:​00!22:​00:​00!22:​30:​00!23:​00:​00!23:​30:​00!"​ \ 
---field="​${warning[@]}":​BTN " " \ 
---button="​gtk-cancel:​2"​ \ 
---button="​Menu:​1"​ \ 
---button="​Enregistrer les métadonnées:​0"​) 
-  
-yadID="​$?"​ 
-  
-yadDate=$(awk -F[\|] '​{print $6,​$9}'​ <<<​ "​${yadDate}}"​) 
-  
-# Navigation 
-if [[ $yadID -eq "​0"​ ]]; then 
- EDIT 
-  
-elif [[ $yadID -eq "​1"​ ]]; then 
- YADMENU 
-  
-elif [[ $yadID -eq "​2"​ ]]; then 
- YADMENU 
-  
-elif [[ $yadID -eq "​252"​ ]]; then 
- exit 
-  
-fi 
-} 
-#​======================================================================================================================================= 
-function EDIT() 
-{ 
-exiftool -AllDates="​${yadDate}"​ -overwrite_original "​${cheminImage}"​ 
-exiftool "​${cheminImage}"​ 
-  
-# Mémorisation du dernier dossier ouvert 
-a=$(awk 'NR==1 {printf "​%s\n"​ ,$0}' <<<​ "​${cheminImage}"​) 
-b="​${a%/​*}"​ 
-cheminDossier=$(awk '​{printf "​%s/"​ ,$0}' <<<​ "​${b}"​) 
-  
-YADMENU 
-} 
-#​======================================================================================================================================= 
-function YADFICHIERMULTIPLE() 
-{ 
-cheminImage=$(yad --file \ 
---multiple \ 
---title "​SlyExif"​ \ 
---width="​700"​ \ 
---height="​500"​ \ 
---separator="​\n"​ \ 
---center \ 
---filename="​${cheminDossier}"​ \ 
---file-filter="​Images (jpg - jpeg - png)| *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG" \ 
---file-filter "Tous | *" \ 
---button="​Menu:​1"​ \ 
---button="​Suivant:​0"​) 
-  
-yadID="​$?"​ 
-  
-# Navigation 
-if [[ $yadID -eq "​0"​ ]]; then 
- YADINFOFICHIERNETTOYER 
-  
-elif [[ $yadID -eq "​1"​ ]]; then 
- YADMENU 
-  
-elif [[ $yadID -eq "​252"​ ]]; then 
- exit 
-  
-fi 
-} 
-#​======================================================================================================================================= 
-YADINFOFICHIERNETTOYER() 
-{ 
-yadchoix=$(yad --form \ 
---title="​SlyExif"​ \ 
---center \ 
---scroll \ 
---width="​700"​ \ 
---height="​500"​ \ 
---button="​Menu:​1"​ \ 
---button="​Supprimer les métadonnées:​0"​ \ 
---image="​gtk-dialog-warning"​ \ 
---field="​ ":LBL ""​ \ 
---field="​Supprimer toutes les métadonnées y compris les dates":​CHK "​FALSE"​ \ 
---field="<​span foreground='​red'><​b>​\n\nFichier(s) dont les métadonnées seront supprimées ! </​b></​span>":​LBL ""​ \ 
---field="​ ":LBL ""​ \ 
---field="":​LBL ""​ \ 
---field="​ ":LBL ""​ \ 
---field="​${cheminImage}":​LBL ""​) 
-  
-yadchoix=$(awk -F[\|] '​{print $2}' <<<​ "​${yadchoix}"​) 
-  
-yadID="​$?"​ 
-  
-# Navigation 
-if [[ "​${yadID}"​ -eq "​0"​ ]]; then  
- NETTOYAGE 
-  
-elif [[ $yadID -eq "​1"​ ]]; then 
- YADMENU 
-  
-elif [[ $yadID -eq "​252"​ ]]; then 
- exit 
-  
-fi 
-} 
-#​======================================================================================================================================= 
-function NETTOYAGE() 
-{ 
-# Calcul nombre fichiers sélectionnés 
-IFS=$'​\n'​  
- 
-nbrFichier=0 
-  
-for i in ${cheminImage};​ do 
- ((nbrFichier+=1)) 
-done 
- 
-pourcentFichier=$(echo "​scale=9;​ 100/​${nbrFichier}"​ | bc) 
- 
-pourcent="​0"​ 
-nbr="​1"​ 
- 
-IFS=$'​\n'​  
- 
-for i in ${cheminImage};​ do 
-  
- extention=$(awk -F [.] '​{print $NF}' <<<​ "​${i}"​) 
-  
- if [[ ${extention} == "​jpg"​ ]] || [[ ${extention} == "​JPG"​ ]] ||  
- [[ ${extention} == "​jpeg"​ ]] || [[ ${extention} == "​JPEG"​ ]] ||  
- [[ ${extention} == "​png"​ ]] || [[ ${extention} == "​PNG"​ ]]; then 
-  
- dateSave=$(exiftool "​${i}"​ | awk '/​Date\/​Time Original/ {print $(NF-1),​$NF}'​) 
-  
- exiftool -all= "​${i}"​ -overwrite_original 
-  
- if [[ "​${yadchoix}"​ == "​FALSE"​ ]]; then 
-  
- exiftool -AllDates="​${dateSave}"​ -overwrite_original "​${i}"​ 
- fi 
-  
- exiftool "​${i}"​ 
-  
- # Mémorisation du dernier dossier ouvert 
- a=$(awk 'NR==1 {printf "​%s\n"​ ,$0}' <<<​ "​${i}"​) 
- b="​${a%/​*}"​ 
- cheminDossier=$(awk '​{printf "​%s/"​ ,$0}' <<<​ "​${b}"​) 
-  
- pourcent=$(echo "​scale=9;​ (${pourcent} + ${pourcentFichier})"​ | bc)  
- pourcentDigit=$(awk '​{printf "​%d"​ ,$1}' <<<​ "​${pourcent}"​) 
-  
- if [[ "​${pourcentDigit}"​ -ge "​100"​ ]]; then  
- echo "​99"​ 
- echo -e "​\n#​Nombre de fichiers modifiés ${nbr} sur ${nbrFichier}"​ 
- sleep 3 
-  
- else 
- echo "​${pourcent}"​ 
- ((nbr+=1)) 
- echo -e "​\n#​Nombre de fichiers modifiés ${nbr} sur ${nbrFichier}"​ 
- fi 
- 
- else 
-  
- echo "​ERREUR ! Fichier pas pris en charge par SlyExif."​ 
-  
- fi 
-  
-done | yad --progress --title="​SlyExif"​ --auto-close --auto-kill 
- 
-YADMENU 
-} 
-#​======================================================================================================================================= 
-  
-# Lancement du script 
- 
-etatPaquet=$(dpkg --get-selections | awk '{if ($1 == "​yad"​) {print $2}}') 
-[[ "​${etatPaquet}"​ !=  "​install"​ ]] && echo -e "\nLe paquet \"​yad\"​ n'est pas installé, merci de l'​installer.\n"​ && exit 
- 
-etatPaquet=$(dpkg --get-selections | awk '{if ($1 == "​libimage-exiftool-perl"​) {print $2}}') 
-[[ "​${etatPaquet}"​ !=  "​install"​ ]] && echo -e "\nLe paquet \"​libimage-exiftool-perl\"​ n'est pas installé, merci de l'​installer.\n"​ && exit 
- 
-etatPaquet=$(dpkg --get-selections | awk '{if ($1 == "​ffmpeg"​) {print $2}}') 
-[[ "​${etatPaquet}"​ !=  "​install"​ ]] && echo -e "\nLe paquet \"​ffmpeg\"​ n'est pas installé, merci de l'​installer.\n"​ && exit 
- 
-cheminDossier="​$HOME/​Images"​ 
-[[ ! -d "​$HOME/​.slyexif"​ ]] && mkdir "​$HOME/​.slyexif"​ 
-  
-YADMENU 
-</​file>​ 
utilisateurs/slyfox/scripts/slyexif.1497648243.txt.gz · Dernière modification: 16/06/2017 23:24 par Slyfox

Pied de page des forums

Propulsé par FluxBB