added the process image function