Renaming source files to remove problematic character

Rework rotation of the images
This commit is contained in:
2019-05-22 13:44:19 +02:00
parent 3775d4ddd2
commit 8e169bb1f5

View File

@@ -20,7 +20,7 @@ fnPath=""
STARTTIME=$(date +%s)
# drop CIFS cache in case target files existed before
sync; echo 3 > /proc/sys/vm/drop_caches;
#sync; echo 3 > /proc/sys/vm/drop_caches;
for file in "$sourceDir"/**/*.{jpg,JPG,jpeg,JPEG}
do
@@ -29,14 +29,15 @@ do
continue
fi
case $file in
*[[:space:]]*)
# replace all blanks
mv "${file}" "${file// /_}"
file=${file// /_}
echo "Space replaced: ${file}"
;;
esac
# replace all blanks and brakets
exp='[() ]'
if [[ "$file" =~ $exp ]]
then
fileNew=${file//$exp/_}
mv "${file}" "$fileNew"
file="$fileNew"
echo "Space replaced: ${file}"
fi
fnNoExt="${file%.*}"
fnExt="${file##*.}"
@@ -58,11 +59,17 @@ do
echo $result
fi
# Auto rotate source image according to exif orientation information
#auto rotate source image according to exif orientation information
orient=$(exiftool -Orientation "${file}")
if [ ! -z "${$orient##*"normal"*}" ]; then
mogrify -auto-rotate -quality 94 "${file}" #> /dev/null 2>&1
if [[ $orient != *"normal"* ]]; then
quali=$(identify -format '%Q' "${file}")
if [ "$quali" -le "0" ]; then
quali=94
fi
echo "rotate with quality $quali : $file"
mogrify -auto-orient -quality ${quali} "${file}" #> /dev/null 2>&1
fi
#echo "MISSING! ${destDir}${fnNoExt}-me.${fnExt}"
#Store correctly oriented base image (medium) in memory. All other thumbnails are created from this
convert "${file}" -auto-orient -thumbnail 1008x756^ -write mpr:baseline +delete \
@@ -71,7 +78,6 @@ do
mpr:baseline -thumbnail 150x9999 -write "${destDir}${fnNoExt}-cu_s150x9999.${fnExt}" +delete \
mpr:baseline -thumbnail 144x144 -write "${destDir}${fnNoExt}-th.${fnExt}" +delete \
mpr:baseline -define jpeg:size=144x144 -thumbnail 120x120^ -gravity center -extent 120x120 "${destDir}${fnNoExt}-sq.${fnExt}"
#mpr:baseline -resize 240x240 -write "${destDir}${fnNoExt}-2s.${fnExt}" +delete \
fi
counter=$[$counter +1]
if [ $(($counter%100)) -eq 0 ]; then
@@ -80,7 +86,7 @@ do
fi
done
chown -R www-data: ${destDir}
chown -R www-data:pi ${destDir}../
ENDTIME=$(date +%s)
echo "It took $((($ENDTIME - $STARTTIME)/60)) minutes to complete this task..."