2_convert 2.4 KB

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