Guest User

Untitled

a guest
Apr 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. rootdir="."
  4. background_file_name="background.jpg"
  5.  
  6. if [ $# -eq 2 ]; then
  7.     rootdir=$1
  8.     background_file_name=$2
  9. elif [ $# -eq 1 ]; then
  10.     rootdir="."
  11.     background_file_name=$1
  12. fi
  13.  
  14. find "$rootdir" -type d | while read pngdir; do
  15.     if [ -f "$pngdir/$background_file_name" ];
  16.     then
  17.     echo "Background file found in $pngdir/$background_file_name"
  18.    
  19.     find "$pngdir" -name *.png -maxdepth 1 | while read foreground_file; do
  20.         echo "processing $foreground_file with $pngdir/$background_file_name"
  21.         mkdir -p "$pngdir/merged"                  
  22.         ./composite -gravity center -compress Lossless "$foreground_file" "$pngdir/$background_file_name" "$pngdir/merged/`basename -s .png \"$foreground_file\"`.jpg"
  23.     done
  24.     fi
  25. done
Add Comment
Please, Sign In to add comment