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