code with the stuff to work with images precaptured