Fix out of bounds access grabbing the filename from the image path.