2_convert 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 /home/pi/_Pictures/$IMG /ramfs/
  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 "Blaise Atro - Mission BOB du 03 - F4KOA-AM" /ramfs/lit-$IMG
  24. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+50 " $(date -u --date=@$(date "+%s"))" /ramfs/lit-$IMG
  25. echo "=> Adding GPS Position"
  26. # On cherche à voir si on a la position GPS ou non dans le exif
  27. exiftool /home/pi/_Pictures/$IMG | grep -e "GPS Position" -e "GPS Altitude"
  28. echo $?
  29. if [ $? -eq 0 ]
  30. then
  31. GPS_POS=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Position" | cut -d":" -f2)
  32. ALTITUDE=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Altitude" | cut -d":" -f2)
  33. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : $ALTITUDE" /ramfs/lit-$IMG
  34. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "$GPS_POS" /ramfs/lit-$IMG
  35. else
  36. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : Unknown" /ramfs/lit-$IMG
  37. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "NO GPS." /ramfs/lit-$IMG
  38. fi
  39. echo " => Converting image to WAV..."
  40. cd ~/PySSTV/
  41. source bin/activate
  42. python -m pysstv --mode PD120 --rate 44100 --bits 16 --vox --fskid "F4IYQ" /ramfs/lit-$IMG /ramfs/totx.wav
  43. deactivate
  44. echo "=> Setting flag that can be Tx"
  45. touch /ramfs/.canbetx
  46. rm -rf /ramfs/lit-$IMG
  47. echo -n ""