Updated to work on any capture size