nunosempere.com/blog/2023/01/03/me-in-2022/index.md
2023-01-09 11:00:09 +00:00

1.8 KiB

Me in 2022

The above .gif shows a snapshot taken by my computer at 12:00 for a large number of days of the year. The below .gif shows a snapshot taken by my computer every five minutes on the 22/02/2022:

To create such a .gif in Linux

a. Create a script to take a photo from your webcam:

## Defs
panopticonDir="~/.panopticon"

selfiesDir="$panopticonDir/selfies"
today="$(date +"%Y%m%d")"
timeNow="$(date +"%H%M%S")"

## Init
mkdir -p "$selfiesDir/$today"

## Selfies

selfieFileName="webcam_$timeNow.jpg"
/usr/bin/fswebcam -r 1280x720 "$selfiesDir/$today/$selfieFileName" 
# ^ works with pipewire

b. Call the script from within crontab

Call

$ sudo crontab -e

and then paste:

*/5 * * * * /home/loki/.panopticon/shoot.sh

c. Put it all together into a gif

One gif from snapshots taken at 12:00.

summary_dir="~/.panopticon/summary-12"
mkdir summary_dir
for dir in ~/.panopticon/*/ ; do
  if [[ -d "$dir" && ! -L "$dir" ]]; then
    echo "Entering $dir";
    dirname_raw="$(echo "$dir" | sed 's#/##')"
    temp_photo_name="$(echo $dirname_raw/webcam_1200*)"
    echo "$temp_photo_name"
    cp $temp_photo_name temp.jpg
    mv temp.jpg $summary_dir/$dirname_raw.jpg
  fi;
done

convert -delay 10 -loop 0 $summary_dir/*.jpg 12.gif

One for each day with something like:

for dir in */ ; do
  if [[ -d "$dir" && ! -L "$dir" ]]; then
    echo "Entering $dir";
    dirname_raw="$(echo "$dir" | sed 's#/##')"
    convert -delay 10 -loop 0 $dirname_raw/*.jpg daily-gifs/$dirname_raw.gif
    echo "Created daily_gifs/$dirname_raw"
  fi;
done