postprocess.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # The post-processing script gets called after taking a burst of
  3. # pictures into a temporary directory. The first argument is the
  4. # directory containing the raw files in the burst. The contents
  5. # are 1.dng, 2.dng.... up to the number of photos in the burst.
  6. #
  7. # The second argument is the filename for the final photo without
  8. # the extension, like "/home/user/Pictures/IMG202104031234"
  9. #
  10. # The post-processing script is responsible for cleaning up
  11. # temporary directory for the burst.
  12. if [ "$#" -ne 2 ]; then
  13. echo "Usage: $0 [burst-dir] [target-name]"
  14. exit 2
  15. fi
  16. BURST_DIR="$1"
  17. TARGET_NAME="$2"
  18. # Copy the first frame of the burst as the raw photo
  19. cp "$BURST_DIR"/1.dng "$TARGET_NAME.dng"
  20. # Create a .jpg if raw processing tools are installed
  21. DCRAW=""
  22. if command -v "dcraw_emu" &> /dev/null
  23. then
  24. DCRAW=dcraw_emu
  25. fi
  26. if command -v "dcraw" &> /dev/null
  27. then
  28. DCRAW=dcraw
  29. fi
  30. if [ -n "$DCRAW" ]; then
  31. # +M use embedded color matrix
  32. # -H 4 Recover highlights by rebuilding them
  33. # -o 1 Output in sRGB colorspace
  34. # -q 3 Debayer with AHD algorithm
  35. # -T Output TIFF
  36. # -fbdd 1 Raw denoising with FBDD
  37. $DCRAW +M -H 4 -o 1 -q 3 -T -fbdd 1 $BURST_DIR/1.dng
  38. if command -v convert &> /dev/null
  39. then
  40. convert "$BURST_DIR"/1.dng.tiff "$TARGET_NAME.jpg"
  41. else
  42. cp "$BURST_DIR"/1.dng.tiff "$TARGET_NAME.tiff"
  43. fi
  44. fi
  45. # Clean up the temp dir containing the burst
  46. rm -rf "$BURST_DIR"