Intro

This post started as an example session of writing for Jekyll during a hack-and-tell afterparty. I was showing a simple shell script to compress JPEG images prior to publishing. We then decided to run it recursively. veox for keyboard jockey, ioch as an arbiter, nightshade for coding.

Result

Process

We used a standard lenna image.

jpgcompress

#!/bin/sh
# TODO: run recursively

tmpfile="/tmp/jpegcompress.pnm"

for f in $1; do
    djpeg $f > $tmpfile
    cjpeg -quality $2 $tmpfile > $f
done

rm $tmpfile

compress-recursively

#!/bin/zsh

filename=lenna.jpg

convert lenna.png $filename

for i in `seq 1 1000`; do
    echo "$i"
    cp $filename `printf "%06d.jpg" $i`
    jpgcompress $filename $(((1000-i)/10))
done

Note: quantization starts showing at iteration 761.

Intermediate results

begin middle nearend end

Create video from jpeg images

ffmpeg -i %06d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -i %06d.jpg -c:v theora -r 30 -pix_fmt yuv420p out.ogg