Image exif_transpose not working with Pillow 7

  python, python-imaging-library

I am working on setting up image data set for styleGAN

I got this error TypeError: write_undefined() takes 2 positional arguments but 5 were given

I’d really appreciated if you can help! thanks

import os
import glob
from PIL import Image
from PIL import ImageOps

imgDir = "/content/drive/MyDrive/EXIF" #@param {type:"string"}
imgOutDir = "/content/drive/MyDrive/2B/GAN_output" #@param {type:"string"}
width = 1024 #@param {type:"integer"}
height = 1024 #@param {type:"integer"}

files = glob.glob(imgDir + '/*')
print(files)
for f in files:
    title, ext = f.split('.')
    print(title, ext)
    if ext in ['jpg', 'png', 'jpeg', 'JPG', 'PNG', 'JPEG']:
        img = Image.open(f)
        ImageOps.exif_transpose(img)
        _width, _height = img.size
        
        size = 0
        if _width > _height:
            size = _height
        else:
            size = _width
        
        left = (_width - size) / 2
        top = (_height - size) / 2
        right = (_width + size) / 2
        bottom = (_height + size) / 2
        
        folder  = title.split("/")[:-1]
        file_name = title.split("/")[-1]
        img = img.crop((left, top, right, bottom))
        img_resize = img.resize((width, height))
       

Source: Python Questions

LEAVE A COMMENT