from PIL import Image
from tempfile import NamedTemporaryFile
import os


def is_image_compressable(path):
    ACCEPTABLE = [".jpg", ".png"]
    ext = os.path.splitext(path)[1].lower()
    return ext in ACCEPTABLE


def _detect_valid_format(path):
    ext = os.path.splitext(path)[1].lower()
    return {".jpg": "jpeg", ".png": "png"}.get(ext)


def compress(path):
    im = Image.open(path)
    size = (1024, 1024)
    im.thumbnail(size, Image.ANTIALIAS)
    with NamedTemporaryFile(delete=False) as temp:
        im.save(temp, _detect_valid_format(path))
        return temp

@@ -352,24 +352,43 @@
 ompress(path
+, size=(1024, 1024)
 ):%0A    im = 
@@ -408,32 +408,8 @@
 th)%0A
-    size = (1024, 1024)%0A
     

add size option to compress func