from PIL import Image
import glob
import os
import pdb

if __name__ == "__main__":
    root_testHR=os.path.expanduser('/mnt/server5_hard1/seungjun/KAIR-master/testsets/testH')

    root_X2='/mnt/server5_hard1/seungjun/KAIR-master/testsets/testL/X2/'
    root_X3 ='/mnt/server5_hard1/seungjun/KAIR-master/testsets/testL/X3/'
    root_X4 ='/mnt/server5_hard1/seungjun/KAIR-master/testsets/testL/X4/'


    scaling_factor=[2,3,4]
    save_dirs=[root_X2, root_X3, root_X4]
    

    for filename in glob.glob(root_testHR + '**/*'):  # assuming gif
        img_=Image.open(filename).convert('RGB')

        img_name=filename.split('/')
        img_name=img_name[-1]
        for idk,savek in zip(scaling_factor, save_dirs):
            img_down = img_.resize((img_.width//idk, img_.height//idk))
            
            save_dir=savek+img_name
            #save_dir=save_dir.split('.png')[0]
            #save_dir=save_dir+'x'+str(idk)+'.png'
            print("saving {}".format(save_dir))
            img_down.save(save_dir)