This code lets you run sql on images.
./img_sql.py -i samples/matrix.jpg \
-o samples/matrix_out.jpg \
-s 'update pixels set r = g, b = r, g = b where x > 700;
update pixels set r = b, b = g, g = r where x < 700 and y > 200;
update pixels set r = g, b = r, g = b where x > 1200;
update pixels set r = g, b = r, g = b where x + y > 1100;
update pixels set r = 250 where x > 100 and x < 400 and y * x > 50000'