1
0
Fork 0

Add genimagecomparisonframes

This commit is contained in:
Starbeamrainbowlabs 2016-05-24 19:49:08 +01:00
parent 67095c9a45
commit 356ef8998d
2 changed files with 51 additions and 0 deletions

View File

@ -26,6 +26,7 @@ Here's a list of the most interesting ones, along with what they do and where th
- [micro](https://github.com/zyedidia/micro) - A new (experimental) terminal-based text editor.
- [tig](http://jonas.nitro.dk/tig/) - A terminal-based git repository browser.
- backup - A script I wrote to make using Duplicity easier.
- genimagecomparisonframes - Another script I wrote to generate the frames for the first half of [this video](https://starbeamrainbowlabs.com/blog/images/20160525-Tessellator-Comparison.webm).
## Disclaimer
I don't own many of the tools in this repository. If you are an owner of one of these tools and I haven't linked to you, please let me know as I probably forgot.

50
genimagecomparisonframes Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
if [[ "$#" -ne 4 ]]
then
echo Side by side image generator
echo By Starbeamrainbowlabs
echo -e "\nUsage:"
echo " ./genframes.sh [leftimage.ext] [rightext.ext] [step] [outdir]"
echo -e "\nNote that the output directory should *not* contain the trailing slash."
exit
fi
i=0
step="$3"
imwidth=1680
imheight=1050
leftimage="$1"
rightimage="$2"
outdirprefix="$4/"
frame=0
while [ $(echo "$i <= 1" | bc) -eq 1 ]
do
nextoffset=$(calc -p "(${imwidth} / 2) * ${i}")
leftpixcount=$(calc -p "$i * $imwidth")
rightpixcount=$(calc -p "$imwidth - $leftpixcount")
framefilename=${outdirprefix}$(printf "%03d" "$frame").jpeg
echo $frame: $leftpixcount / $rightpixcount $framefilename
if [[ $(echo "$leftpixcount == 0" | bc) -eq 1 ]]
then
cp $rightimage $framefilename
elif [[ $(echo "$rightpixcount == 0" | bc) -eq 1 ]]
then
cp $leftimage $framefilename
else
convert $leftimage -crop ${leftpixcount}x${imheight}+0+0 $rightimage -crop ${rightpixcount}x${imheight}+$leftpixcount+0 +append "$framefilename"
fi
frame=$(calc -p "$frame + 1")
i=$(calc -p "$i + $step")
done