Last active
June 3, 2021 20:16
-
-
Save foozmeat/4600169 to your computer and use it in GitHub Desktop.
A bash script to take screenshot every 60 seconds and then add a timestamp to it. Useful for creating time-lapse videos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Help from http://dptnt.com/2009/08/add-date-time-stamp-to-jpeg-photos-using-free-software-mac-linux-nix-edition/ | |
# install the LCD font - http://www.dafont.com/digital-7.font | |
# install imagemagick via homebrew | |
# Install Time Lapse Assembler to make the movie - http://www.dayofthenewdan.com/projects/time-lapse-assembler-1/ | |
set -e | |
font="$HOME/Library/Fonts/digital-7 (mono).ttf" | |
outputfolder="$HOME/Downloads/caps" | |
# Format is x,y,width,height. Origin is the upper-left corner | |
rect="403,94,1061,1026" | |
delay=2 | |
fontFill="black" | |
################################################################ | |
mkdir -p ${outputfolder} | |
while [ 1 ];do | |
date=$(date +%d\-%m\-%Y\_%H.%M.%S) | |
file="/tmp/${date}.png" | |
screencapture -t png -R${rect} -x ${file} | |
output="${outputfolder}/${date}.png" | |
# Get the file dimension | |
dim=$(identify -format "%w %h" "$file") | |
width=${dim%% *} | |
height=${dim#* } | |
# file date | |
MODDATE=$(stat -f "%Sm" $file) | |
# Decide the font size automatically | |
if [ $width -ge $height ] | |
then | |
pointsize=$(($width/30)) | |
else | |
pointsize=$(($height/30)) | |
fi | |
echo "Writing file: $output" | |
convert "$file" -gravity SouthEast -font "$font" -pointsize $pointsize -fill ${fontFill} -annotate +$pointsize+$pointsize "${MODDATE}" "$output" | |
rm ${file} | |
sleep ${delay} | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment