Implement image_to_cursor to avoid redundant code