2_convert 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "https://f4koa.fr - Ballon Planète-Sciences - 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. if $? -eq 0; then
  29. GPS_POS=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Position" | cut -d":" -f2)
  30. ALTITUDE=$(exiftool /home/pi/_Pictures/$IMG | grep "GPS Altitude" | cut -d":" -f2)
  31. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : $ALTITUDE" /ramfs/lit-$IMG
  32. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "$GPS_POS" /ramfs/lit-$IMG
  33. else
  34. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : Unknown" /ramfs/lit-$IMG
  35. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "NO GPS." /ramfs/lit-$IMG
  36. fi
  37. echo " => Converting image to WAV..."
  38. cd ~/PySSTV/
  39. source bin/activate
  40. python -m pysstv --mode PD120 --rate 44100 --bits 16 --vox --fskid "F4IYQ" /ramfs/lit-$IMG /ramfs/totx.wav
  41. deactivate
  42. echo "=> Setting flag that can be Tx"
  43. touch /ramfs/.canbetx
  44. rm -rf /ramfs/lit-$IMG
  45. echo -n ""