|
@@ -1,12 +1,13 @@
|
|
|
-import cv2
|
|
|
import os
|
|
|
+import typing as T
|
|
|
+
|
|
|
+import cv2
|
|
|
|
|
|
from PIL import Image
|
|
|
-from typing import Tuple
|
|
|
-from typing import Optional
|
|
|
|
|
|
from pycs.database.File import File
|
|
|
|
|
|
+# pylint: disable=too-many-arguments, invalid-name, too-many-locals
|
|
|
def crop_file(file: File, project_root: str, x: float, y: float, w: float, h: float) -> str:
|
|
|
"""
|
|
|
gets a file for the given file_id, crops the according image to the
|
|
@@ -46,7 +47,10 @@ def crop_file(file: File, project_root: str, x: float, y: float, w: float, h: fl
|
|
|
return os.path.split(target_path)
|
|
|
|
|
|
|
|
|
-def resize_file(file: File, project_root: str, max_width: int, max_height: int) -> Tuple[str, str]:
|
|
|
+def resize_file(file: File,
|
|
|
+ project_root: str,
|
|
|
+ max_width: int,
|
|
|
+ max_height: int) -> T.Tuple[str, str]:
|
|
|
"""
|
|
|
If file type equals video this function extracts a thumbnail first. It calls resize_image
|
|
|
to resize and returns the resized files directory and name.
|
|
@@ -77,7 +81,10 @@ def resize_file(file: File, project_root: str, max_width: int, max_height: int)
|
|
|
|
|
|
return os.path.split(abs_file_path)
|
|
|
|
|
|
-def resize_image(file_path: str, target_path: str, max_width: int, max_height: int) -> Optional[bool]:
|
|
|
+def resize_image(file_path: str,
|
|
|
+ target_path: str,
|
|
|
+ max_width: int,
|
|
|
+ max_height: int) -> T.Optional[bool]:
|
|
|
"""
|
|
|
resize an image so width < max_width and height < max_height
|
|
|
|