Added basename() to make automatically naming images easier.