BILOW library trying to open file before saving

Hello Guys Please Urgent Help please

i have a function to return upload path for images and videos as follows
for uploading photos

def directory_path(instance, filename):
    imgName, extension = filename.split('.')
    imgName = instance.title
    return 'images/%s.%s' %(imgName, extension)

when i trying to upload an image i got

that happens because of this line of self save method

what to do to make the function save the photo first and then open its thumbnail

here is the post model

class Post(models.Model):
    id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, primary_key=True)
    title = models.CharField(max_length=200, db_index=True, blank=False, default='')
    slug = models.SlugField(max_length=200, db_index=True, unique=True, blank=True, editable=True) 
    tag = models.ManyToManyField(Tag, blank=True, help_text="Select a tag for this post", related_name='post_tags')
    created_at = models.DateTimeField('publish_date', auto_now_add=True) # 'publish_date' is verbose_name
    updated_at = models.DateTimeField(auto_now=True)
    creator = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="post_creators") # show creator of the post(admin or employee user)
    post_img = models.ImageField(upload_to=directory_path, null=False, blank=True, default ="img.png") # upload_to ="/media/post_images"
    maintainer = models.ForeignKey(Maintainer, on_delete=models.SET_NULL, blank=True, null=True, related_name='post_maintainers')
    content = models.TextField(max_length=1000, help_text="Enter descriptive subject")
    video = models.FileField(upload_to=upload_path, null=True, blank=True)
    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(self.title)
        img = Image.open(self.post_img.path) 
        if img.height > 400 or img.width > 400:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.post_img.path)
        return super(Post, self).save(*args, **kwargs)

do i have to put the line

        img = Image.open(self.post_img.path) 

after saving method or what

please help me