If I understand well
os.path.basename
is used to get the original name of the image, we can do without it, just by creating any file within open
. When you two write a code it looks very simple.