Changed how it gets the directory of the image opened