2_convert 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. source ~/BallonSonde/variables.sh
  5. while [[ ! -f /ramfs/.canbeconvert ]]; do
  6. sleep 1
  7. echo "wait for file to convert..."
  8. done
  9. IMG=$(cat /ramfs/.canbeconvert)
  10. echo "=> File $IMG detected !"
  11. #############
  12. # Mode SSTV
  13. while [[ -f "/ramfs/totx.wav" ]]; do
  14. echo "=> Skipping convert, because old one is not yet Txed !"
  15. sleep 5
  16. done
  17. # On traite l'image...
  18. echo "=> Copying picz in RAMFS"
  19. cp ~/_Pictures/$IMG /ramfs/
  20. echo "=> Converting to PD120 Format <long>x496"
  21. convert /ramfs/$IMG -resize 660x496^ /ramfs/lit-$IMG
  22. rm -rf /ramfs/$IMG
  23. echo "=> Adding annotaion"
  24. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+10 $SSTV_BANNER /ramfs/lit-$IMG
  25. 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
  26. echo "=> Adding GPS Position"
  27. # On cherche à voir si on a la position GPS ou non dans le exif
  28. exiftool ~/_Pictures/$IMG | grep -e "GPS Position" -e "GPS Altitude"
  29. echo $?
  30. if [ $? -eq 0 ]
  31. then
  32. GPS_POS=$(exiftool ~/_Pictures/$IMG | grep "GPS Position" | cut -d":" -f2)
  33. ALTITUDE=$(exiftool ~/_Pictures/$IMG | grep "GPS Altitude" | cut -d":" -f2)
  34. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : $ALTITUDE" /ramfs/lit-$IMG
  35. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "$GPS_POS" /ramfs/lit-$IMG
  36. else
  37. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : Unknown" /ramfs/lit-$IMG
  38. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "NO GPS." /ramfs/lit-$IMG
  39. fi
  40. echo " => Converting image to WAV..."
  41. cd ~/PySSTV/
  42. source bin/activate
  43. python -m pysstv --mode PD120 --rate 44100 --bits 16 --vox --fskid $INDICATIF /ramfs/lit-$IMG /ramfs/totx.wav
  44. deactivate
  45. echo "=> Setting flag that can be Tx"
  46. touch /ramfs/.canbetx
  47. rm -rf /ramfs/lit-$IMG
  48. echo -n ""