App/Model.py
def export_shapes(self, tfpn, tsufix):
        """
        Export images from source files into target files with CV2

        Args:
            tfpn (list): local filepaths of target images
            tsufix (dict): target image file sufix, ie.: "-rgb"

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): relative filepaths for the target images
        """
        try:
            # default answer
            ans = dict()
            wans = dict()
            for key in tsufix.keys():
                wans[key] = str()

            # checking if list have images
            if len(tfpn) > 0:

                # checking if the target files and the keys equal
                if len(tfpn) == len(tsufix.keys()):

                    # iterating ordered keys
                    sort_sufix = sorted(tsufix.keys(), reverse=False)
                    for tf, key in zip(tfpn, sort_sufix):
                        tf = str(tf)
                        # default temporal variables
                        tdf = None
                        complete = False
                        tshape = list()

                        # checking if it is RGB
                        # if any("rgb" in s for s in (tf, key)):
                        if "rgb" in tf:
                            # opening file in RBG
                            tdf = cv2.imread(tf, cv2.IMREAD_UNCHANGED)
                            # exporting/saving to RBG shape
                            tshape = list(tdf.shape)
                            complete = True

                        # checking if it is B&W
                        # elif any("bw" in s for s in (tf, key)):
                        if "bw" in tf:
                            # opening file in B&W
                            tdf = cv2.imread(tf, cv2.IMREAD_GRAYSCALE)
                            # exporting/saving to B&W shape
                            tshape = list(tdf.shape)
                            complete = True

                        # updating answer dict
                        if complete is True:
                            td = {key: tshape}
                            wans.update(td)

            # # returning answer
            ans = copy.deepcopy(wans)
            return ans

        # exception handling
        except Exception as exp:
            Err.reraise(exp, "Gallery: export_shapes")

        Export images from source files into target files with CV2

        Args:
            tfpn (list): local filepaths of target images
            tsufix (dict): target image file sufix, ie.: "-rgb"

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): relative filepaths for the target images
        
Export images from source files into target files with CV2
Export images from source files into target files with CV2
def export_shapes(self, tfpn, tsufix):
        try:
            ans = dict()
            wans = dict()
            for key in tsufix.keys():
                wans[key] = str()
            if len(tfpn) > 0:
                if len(tfpn) == len(tsufix.keys()):
                    sort_sufix = sorted(tsufix.keys(), reverse=False)
                    for tf, key in zip(tfpn, sort_sufix):
                        tf = str(tf)
                        tdf = None
                        complete = False
                        tshape = list()
                        if "rgb" in tf:
                            tdf = cv2.imread(tf, cv2.IMREAD_UNCHANGED)
                            tshape = list(tdf.shape)
                            complete = True
                        if "bw" in tf:
                            tdf = cv2.imread(tf, cv2.IMREAD_GRAYSCALE)
                            tshape = list(tdf.shape)
                            complete = True
                        if complete is True:
                            td = {key: tshape}
                            wans.update(td)
            ans = copy.deepcopy(wans)
            return ans
        except Exception as exp:
            Err.reraise(exp, "Gallery: export_shapes")
def export_shapes ( self , tfpn , tsufix ) : try : ans = dict ( ) wans = dict ( ) for key in tsufix . keys ( ) : wans [ key ] = str ( ) if len ( tfpn ) > 0 : if len ( tfpn ) == len ( tsufix . keys ( ) ) : sort_sufix = sorted ( tsufix . keys ( ) , reverse = False ) for tf , key in zip ( tfpn , sort_sufix ) : tf = str ( tf ) tdf = None complete = False tshape = list ( ) if "rgb" in tf : tdf = cv2 . imread ( tf , cv2 . IMREAD_UNCHANGED ) tshape = list ( tdf . shape ) complete = True if "bw" in tf : tdf = cv2 . imread ( tf , cv2 . IMREAD_GRAYSCALE ) tshape = list ( tdf . shape ) complete = True if complete is True : td = { key : tshape } wans . update ( td ) ans = copy . deepcopy ( wans ) return ans except Exception as exp : Err . reraise ( exp , "Gallery: export_shapes" )
Export images from source files into target files with CV2
Export images from source files into target files with CV2
"""
        Export images from source files into target files with CV2

        Args:
            tfpn (list): local filepaths of target images
            tsufix (dict): target image file sufix, ie.: "-rgb"

        Raises:
            exp: raise a generic exception if something goes wrong

        Returns:
            ans (dict): relative filepaths for the target images
        """ # default answer # checking if list have images # checking if the target files and the keys equal # iterating ordered keys # default temporal variables # checking if it is RGB # if any("rgb" in s for s in (tf, key)): # opening file in RBG # exporting/saving to RBG shape # checking if it is B&W # elif any("bw" in s for s in (tf, key)): # opening file in B&W # exporting/saving to B&W shape # updating answer dict # # returning answer # exception handling
ans (dict): relative filepaths for the target images
ans ( dict ) : relative filepaths for the target images
raise a generic exception if something goes wrong
raise a generic exception if something goes wrong
exp
self
tfpn
local filepaths of target images
local filepaths of target images
tsufix
target image file sufix, ie.: "-rgb"
target image file sufix ie . : " - rgb "