Appling code formating

This commit is contained in:
2019-05-22 22:51:32 +02:00
parent 71735652e8
commit 155cb603ca
3 changed files with 72 additions and 72 deletions

112
piwigo_thumbgen.sh Normal file → Executable file
View File

@@ -24,68 +24,68 @@ STARTTIME=$(date +%s)
for file in "$sourceDir"/**/*.{jpg,JPG,jpeg,JPEG}
do
if [[ ! -f "$file" ]]
then
continue
fi
if [[ ! -f "$file" ]]
then
continue
fi
# replace all blanks and brakets
exp='[() ]'
if [[ "$file" =~ $exp ]]
then
fileNew=${file//$exp/_}
mv "${file}" "$fileNew"
file="$fileNew"
echo "Space replaced: ${file}"
fi
# 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##*.}"
fnPath="${file%/*}"
fnPath="${fnPath#$sourceDir}"
fnNoExt="${fnNoExt#$sourceDir}"
fnNoExt="${file%.*}"
fnExt="${file##*.}"
fnPath="${file%/*}"
fnPath="${fnPath#$sourceDir}"
fnNoExt="${fnNoExt#$sourceDir}"
#echo "${fnPath} ${fnNoExt}"
#echo "${fnPath} ${fnNoExt}"
#If the medium thumbnail exists we assume that the rest also exists and skip this image
if [ ! -f "${destDir}${fnNoExt}-me.${fnExt}" ]; then
mkdir -p "${destDir}${fnPath}"
#Error checking
result=$(jpeginfo -c "$file")
if [[ $result != *"[OK]"* ]]
then
echo $result
fi
#If the medium thumbnail exists we assume that the rest also exists and skip this image
if [ ! -f "${destDir}${fnNoExt}-me.${fnExt}" ]; then
#auto rotate source image according to exif orientation information
orient=$(exiftool -Orientation "${file}")
if [[ $orient != *"normal"* ]]; then
quali=$(identify -format '%Q' "${file}")
if [ "$quali" -le "0" ]; then
quali=94
fi
echo "rotate with quality $quali preserving timestamp: $file"
TIMESTAMP="$( ls -l --time-style='+%Y%m%d%H%M.%S' "${file}" | cut --delimiter=' ' --fields=6 )"
mogrify -auto-orient -quality ${quali} "${file}"
touch -t ${TIMESTAMP} "${file}"
fi
mkdir -p "${destDir}${fnPath}"
#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 \
mpr:baseline -write "${destDir}${fnNoExt}-la.${fnExt}" +delete \
mpr:baseline -thumbnail 792x594 -write "${destDir}${fnNoExt}-me.${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 -define jpeg:size=144x144 -thumbnail 120x120^ -gravity center -extent 120x120 "${destDir}${fnNoExt}-sq.${fnExt}"
fi
counter=$[$counter +1]
if [ $(($counter%100)) -eq 0 ]; then
ENDTIME=$(date +%s)
echo "Processed: ${counter} - Executing for $((($ENDTIME - $STARTTIME)/60)) minutes"
fi
#Error checking
result=$(jpeginfo -c "$file")
if [[ $result != *"[OK]"* ]]
then
echo $result
fi
#auto rotate source image according to exif orientation information
orient=$(exiftool -Orientation "${file}")
if [[ $orient != *"normal"* ]]; then
quali=$(identify -format '%Q' "${file}")
if [ "$quali" -le "0" ]; then
quali=94
fi
echo "rotate with quality $quali preserving timestamp: $file"
TIMESTAMP="$( ls -l --time-style='+%Y%m%d%H%M.%S' "${file}" | cut --delimiter=' ' --fields=6 )"
mogrify -auto-orient -quality ${quali} "${file}"
touch -t ${TIMESTAMP} "${file}"
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 \
mpr:baseline -write "${destDir}${fnNoExt}-la.${fnExt}" +delete \
mpr:baseline -thumbnail 792x594 -write "${destDir}${fnNoExt}-me.${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 -define jpeg:size=144x144 -thumbnail 120x120^ -gravity center -extent 120x120 "${destDir}${fnNoExt}-sq.${fnExt}"
fi
counter=$[$counter +1]
if [ $(($counter%100)) -eq 0 ]; then
ENDTIME=$(date +%s)
echo "Processed: ${counter} - Executing for $((($ENDTIME - $STARTTIME)/60)) minutes"
fi
done
chown -R www-data:pi ${destDir}../

View File

@@ -5,18 +5,18 @@ subCatId=1
if [ "$1" != "" ] && [ "$2" != "" ]
then
catId=$1
subCatId=$2
catId=$1
subCatId=$2
fi
perl -w /root/script/piwigo_refresh.pl \
--base_url=https://change.me/gallery \
--site=2 \
--user="-change me-" \
--password="-change me-" \
--directory="/var/www/piwigo/network" \
--caddie=0 \
--privacy_level=4 \
--cat=${catId} \
--subcat=${subCatId}
--base_url=https://change.me/gallery \
--site=2 \
--user="-change me-" \
--password="-change me-" \
--directory="/var/www/piwigo/network" \
--caddie=0 \
--privacy_level=4 \
--cat=${catId} \
--subcat=${subCatId}

View File

@@ -4,9 +4,9 @@ myyear=$(date "+%Y")
if [ "$1" != "" ]
then
myyear=$1
#echo Error subdir parameter missing
#exit 1;
myyear=$1
#echo Error subdir parameter missing
#exit 1;
fi
subDir="$myyear/"
@@ -15,8 +15,8 @@ networkPhotoRoot="/home/network/Qbilder/photos/${subDir}"
if [ ! -e ${networkPhotoRoot} ]
then
echo "${networkPhotoRoot} not found"
exit 1;
echo "${networkPhotoRoot} not found"
exit 1;
fi
/root/script/piwigo_thumbgen.sh "${networkPhotoRoot}" "${piwigoThumbRoot}"