--- /dev/null
+#!/bin/bash
+
+# Change la taille des images d'un répertoire
+
+PROG_NAME=$(basename $0)
+
+size="1024x768"
+
+print_usage()
+{
+ echo "${PROG_NAME} -- Change la taille des images d'un répertoire"
+ echo "Usage: ${PROG_NAME} [OPTIONS...] SRCDIR"
+ echo
+ echo "Options:"
+ echo " -h display this help and exit"
+ echo " -d répertoire de destination (optionel)"
+ echo " -s format (défaut = ${size})"
+ echo
+}
+
+while getopts "d:hs:" flag ;do
+ case ${flag} in
+ h)
+ print_usage
+ exit 0
+ ;;
+ d)
+ destdir="${OPTARG}"
+ ;;
+ s)
+ size="${OPTARG}"
+ ;;
+ ?)
+ echo "${PROG_NAME}: Option invalide: ${OPTARG}."
+ echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
+ exit 1
+ ;;
+ esac
+done
+shift `expr "${OPTIND}" - 1`
+
+# `$#' now represents the number of arguments after the options.
+# `$1' is the first argument, etc.
+if [ $# -gt 1 ]; then
+ echo "${PROG_NAME}: Too many arguments."
+ echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
+ exit 1
+fi
+
+if [ ${#} -ne 1 ]; then
+ echo "${PROG_NAME}: Nom de répertoire manquant."
+ echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
+ exit 1
+fi
+
+dir=${1}
+
+if [ ! -d "${dir}" ]; then
+ echo "${PROG_NAME}: Répertoire absent: ${dir}"
+ echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
+ exit 1
+fi
+
+if [ "${destdir}" != "" ]; then
+ if [ -d "${destdir}" ]; then
+ echo "${PROG_NAME}: Répertoire de destination présent: ${destdir}"
+ echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
+ exit 1
+ fi
+
+ mkdir -p ${destdir}
+ cp -a ${dir}/* ${destdir}
+ dir="${destdir}"
+fi
+
+# Rename JPG -> jpeg
+src="$(find ${dir} -name \*.JPG)"
+
+if [ "${src}" != "" ]; then
+ for f in ${src}; do
+ mv -- "${f}" "${f%.JPG}.jpeg"
+ done
+fi
+
+# Rename jpg -> jpeg
+src="$(find ${dir} -name \*.jpg)"
+
+if [ "${src}" != "" ]; then
+ for f in ${src}; do
+ mv -- "${f}" "${f%.jpg}.jpeg"
+ done
+fi
+
+# Convert jpeg:
+src="$(find ${dir} -name \*.jpeg)"
+
+if [ "${src}" != "" ]; then
+ mogrify -resize ${size} ${dir}/*.jpeg
+fi
+
+# Convert png:
+src="$(find ${dir} -name \*.png)"
+
+if [ "${src}" != "" ]; then
+ mogrify -resize ${size} ${dir}/*.png
+fi