60 lines
1.3 KiB
Bash
Executable file
60 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
source /var/roothome/app/bin/home/shared.sh
|
|
|
|
if [ ! -f /mnt/storage/hot/.mount ]; then
|
|
echo mount hot storage
|
|
notify 'photos_process : hot storage not mounted'
|
|
exit 1
|
|
fi
|
|
|
|
cd /var/roothome/docker/cloud/data/data/cakee/files/media/photo
|
|
|
|
# convert png to jpg
|
|
echo "converting png to jpg.."
|
|
for img in $(ls *.png) $(ls *.PNG); do
|
|
echo "converting $img"
|
|
filename=${img%.*}
|
|
/usr/bin/convert "$filename.png" "$filename.jpg"
|
|
done
|
|
rm *.png *.PNG
|
|
|
|
# rename bad extensions
|
|
echo "renaming jpg.."
|
|
for img in $(ls *.jpeg) $(ls *.JPG) $(ls *.JPEG); do
|
|
echo "renaming $img"
|
|
filename=${img%.*}
|
|
mv "$img" "$filename.jpg"
|
|
done
|
|
|
|
# compress jpg
|
|
echo "compressing jpg.."
|
|
/usr/bin/mogrify -resize 2073600@ *.jpg
|
|
/usr/bin/jpegoptim --size=1000k *.jpg
|
|
|
|
# rename to hash
|
|
for file in *; do
|
|
if [[ -f "$file" ]]; then
|
|
extension="${file##*.}"
|
|
if [ -f "$file" ] && [ "$extension" != "$file" ]; then
|
|
new_name="${file%$extension}"
|
|
else
|
|
new_name="$file"
|
|
extension=""
|
|
fi
|
|
new_name=$(sha1sum "$file" | cut -d\ -f1)
|
|
if [[ "$extension" != "" ]]; then
|
|
new_name="${new_name,,}.$extension"
|
|
else
|
|
new_name="${new_name,,}"
|
|
fi
|
|
mv "$file" "$new_name"
|
|
fi
|
|
done
|
|
|
|
# move to images
|
|
echo "moving.."
|
|
total_photos=$(ls | wc -l)
|
|
mv *.jpg /mnt/storage/hot/media/family/dima/photo/
|
|
notify_silent "photos processed: $total_photos"
|