Pull image processing into function.