2_convert 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. #IMG=$(cd /ramfs; find ./ -type f -name *.jpg -exec readlink -f {} \;)
  3. #IMG=$(ls -t /home/pi/_Pictures | head -1)
  4. while [[ ! -f /ramfs/.canbeconvert ]]; do
  5. sleep 1
  6. echo "wait for file to convert..."
  7. done
  8. IMG=$(cat /ramfs/.canbeconvert)
  9. echo "=> File $IMG detected !"
  10. #############
  11. # Mode SSTV
  12. while [[ -f "/ramfs/totx.wav" ]]; do
  13. echo "=> Skipping convert, because old one is not yet Txed !"
  14. sleep 5
  15. done
  16. # On traite l'image...
  17. echo "=> Copying picz in RAMFS"
  18. cp -r /home/pi/_Pictures/$IMG /ramfs/$IMG
  19. echo "=> Converting to PD120 Format <long>x496"
  20. convert /ramfs/$IMG -resize 660x496^ /ramfs/lit-$IMG
  21. rm -rf /ramfs/$IMG
  22. echo "=> Adding annotaion"
  23. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+10 " Ballon Stratosphérique ENSIL - F4KMH " /ramfs/lit-$IMG
  24. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+50 " $(date "+%a %d %b %y - %X")" /ramfs/lit-$IMG
  25. echo "=> Adding GPS Position"
  26. GPS_POS=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Position" | cut -d":" -f2)
  27. ALTITUDE=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Altitude" | cut -d":" -f2)
  28. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : $ALTITUDE" /ramfs/lit-$IMG
  29. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "$GPS_POS" /ramfs/lit-$IMG
  30. echo " => Converting image to WAV..."
  31. cd ~/PySSTV/
  32. source bin/activate
  33. python -m pysstv --mode PD120 --rate 44100 --bits 16 --vox --fskid "F4IYQ" /ramfs/lit-$IMG /ramfs/totx.wav
  34. deactivate
  35. echo "=> Setting flag that can be Tx"
  36. touch /ramfs/.canbetx
  37. rm -rf /ramfs/lit-$IMG
  38. echo -n ""