Added checking for image types.