I am trying to resize/convert uploaded image before saving:
def resize_convert(image_file, size, file_full_name):
    os.chdir(BASE_DIR + '/convert/')
    file_name = os.path.splitext(os.path.basename(file_full_name))[0]
    file_ext = os.path.splitext(os.path.basename(image_file))[1]
    files = {}
    for i in size:
        cmd = ['convert', image_file, '-resize', i, file_name + i + file_ext]
        subprocess.check_call(cmd, shell=False)
        webp_cmd = ["cwebp", "-q", "100", file_name + i + file_ext, "-o", file_name + '_' + i + '.webp']
        subprocess.check_call(webp_cmd)
        files[i] = os.getcwd() + '/' + file_name + '_' + i + '.webp'
    return files
so from view I passed all necessary params like this :
 for pro in product_files:
      resize_convert(pro.file.name, ["308x412"], pro)
then it throws this error
expected str, bytes or os.PathLike object, not TemporaryUploadedFile
Update:
def resize_convert(_image_file, size, file_full_name):
    image_file = _image_file.temporary_file_path()
    os.chdir(BASE_DIR + '/convert/')
    file_name = os.path.splitext(os.path.basename(file_full_name))[0]
    file_ext = os.path.splitext(os.path.basename(image_file))[1]
 ....
errors:
 File "/home/.../image.py", line 17, in resize_convert
    image_file = _image_file.temporary_file_path()
AttributeError: 'str' object has no attribute 'temporary_file_path'
ERROR:django.request: Internal Server Error: /admin/product/update/7/ (22-06-2019 23:26:21; log.py:228)
Traceback (most recent call last):
  File "/home/../.env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/../.env/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/.../.env/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/../.env/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/.../views.py", line 562, in product_update
    resize_convert(pro.file.name, ["308x412"], pro)
  File "/home/..utils/image.py", line 17, in resize_convert
    image_file = _image_file.temporary_file_path()
AttributeError: 'str' object has no attribute 'temporary_file_path'
 
    