photos_process : migrate to docker.

This commit is contained in:
Dmitry Voronin 2023-11-05 01:16:31 +03:00
parent da2681861e
commit 91f8c2eefb

View file

@ -1,59 +1,6 @@
#!/bin/bash #!/bin/bash
source /var/roothome/app/bin/home/shared.sh in="/var/roothome/docker/cloud/data/data/cakee/files/media/photo/"
out="/mnt/storage/hot/media/family/dima/photo/"
if [ ! -f /mnt/storage/hot/.mount ]; then /usr/bin/docker run --rm -v "${in}":/in -v "${out}":/out voronind.com/photoprocess:latest
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"