Skip to content

Commit

Permalink
tweak script
Browse files Browse the repository at this point in the history
  • Loading branch information
madjin committed Apr 16, 2023
1 parent c3a11f3 commit c2ba23b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/process_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ process_files() {
find "$dir" -type f -name "*.$filetype" -print0 | while IFS= read -r -d '' file; do
echo "Processing $file..."
local base_filename=$(basename "$file" ".$filetype")
echo "Base filename: $base_filename"
local skip_gif=false skip_png=false

# Store the directory path of the current file
local output_dir=$(dirname "$file")

[[ -f "$dir/$base_filename.gif" ]] && skip_gif=true
[[ -f "$dir/$base_filename.png" ]] && skip_png=true

Expand All @@ -30,19 +32,19 @@ process_files() {
for i in {0..5}; do
local yaw=$((i 45 % 315))
local filename="$base_filename-$i.png"
node ./node_modules/.bin/screenshot-glb -i "$file" -w 512 -h 512 -m "orientation=0 0 $yaw" -o "$filename"
node ./node_modules/.bin/screenshot-glb -i "$file" -w 512 -h 512 -m "orientation=0 0 $yaw" -o "$output_dir/$filename"
done

montage "$base_filename"-.png -tile 6x1 -geometry +0+0 -background none -resize 3072x512 "montage-$base_filename.png"
convert -dispose background -delay 50 -loop 0 "$base_filename"-.png "$dir"/"$base_filename.gif"
rm "$base_filename"-.png
montage "$output_dir/$base_filename"-*.png -tile 6x1 -geometry +0+0 -background none -resize 3072x512 "$output_dir/montage-$base_filename.png"
convert -dispose background -delay 50 -loop 0 "$output_dir/$base_filename"-*.png "$output_dir/$base_filename.gif"
rm "$output_dir/$base_filename"-*.png
fi
fi

# Process png files
if [[ $output_type == "png" || $output_type == "both" ]]; then
if [[ $skip_png == false ]]; then
node ./node_modules/.bin/screenshot-glb -i "$file" -w "$output_width" -h "$output_height" -m "orientation=0 0 180" -o "$dir"/"$base_filename.png"
node ./node_modules/.bin/screenshot-glb -i "$file" -w "$output_width" -h "$output_height" -m "orientation=0 0 180" -o "$output_dir/$base_filename.png"
fi
fi
done
Expand Down

0 comments on commit c2ba23b

Please sign in to comment.