original_docstring: 
          Returns
          -------
          A new Segment, cropped and/or scaled as necessary to reach specified dimensions
          
docstring: Returns
  A new Segment, cropped and/or scaled as necessary to reach specified dimensions
docstring_tokens: Returns A new Segment cropped and / or scaled as necessary to reach specified dimensions
code: def crop_scale(self, dimensions: Tuple[int, int]) -> 'Segment':
          """
          Returns
          -------
          A new Segment, cropped and/or scaled as necessary to reach specified dimensions
          """
          segment = self.copy()
          dimensions = Dimensions(*dimensions)
          
          
          def blur(image):
              #return cv2.GaussianBlur(image.astype(float),(99,99),0)
              return cv2.blur(image.astype(float), (30, 30) , 0)
          
  
            
  
          #if segment.aspect_ratio != dimensions.aspect_ratio:
              # Crop segment to match aspect ratio
              #segment = segment.crop_to_aspect_ratio(dimensions.aspect_ratio)
  
          #if segment.dimensions != dimensions:
              # Resize segment to reach final dimensions
              #segment = segment.resize(dimensions)
          
          replace_width = dimensions.width
          replace_height = dimensions.height
              
          if segment.aspect_ratio != replace_width/replace_height:
  
          ##########################################Below 1 AR##################################################
            if segment.aspect_ratio <= 1:
              #print("below 1")
              if segment.size[0] != replace_width:
                segment = segment.resize(width=replace_width)
              if segment.size[1] != replace_height:
                segment = segment.resize(height=replace_height)
  
  
              segment = segment.set_position("center")
              background1 = segment.crop(x1=0,width = (segment.w/2))
              background2 = segment.crop(x1=(segment.w/2),width = (segment.w/2))
  
              if segment.aspect_ratio != 1:
                #print("Not 1:1")
                background1 = background1.resize(width=(replace_width-segment.w)/2)
                background2 = background2.resize(width=((replace_width-segment.w)/2)+1)
  
              background1 = background1.set_position(("left",'center')).fl_image( blur )
              background2 = background2.set_position(("right",'center')).fl_image( blur )
  
              segment = CompositeVideoClip([background1,background2,segment], size=(replace_width,replace_height))
              segment.effects = self.effects
  
          #########################################Above 1080 ratio###############################################
            elif segment.aspect_ratio > round(replace_width/replace_height,2):
              #print("above 1.7")
              if segment.size[1] != replace_height:
                segment = segment.resize(height=replace_height)
              if segment.size[0] != replace_width:
                segment = segment.resize(width=replace_width)
  
  
              test = (replace_height-segment.h)/2
              segment = segment.set_position("center")
              background1 = segment.crop(y1=0,height = ((replace_height-segment.h)/2))
              background2 = segment.crop(y1=segment.h-test,height = test)
  
  
  
              background1 = background1.set_position(('center','top')).fl_image( blur )
              background2 = background2.set_position(('center','bottom')).fl_image( blur )
              segment = CompositeVideoClip([background1,background2,segment], size=(replace_width,replace_height))
              segment.effects = self.effects
  
         ######################################other#######################################################
            elif segment.aspect_ratio > 1 and segment.aspect_ratio < round(replace_width/replace_height,2):
              #print('midway between')
              if segment.size[0] != replace_width:
                segment = segment.resize(width=replace_width)
              if segment.size[1] != replace_height:
                segment = segment.resize(height=replace_height)
  
  
              segment = segment.set_position("center")
              background1 = segment.crop(x1=0,width = (segment.w/2))
              background2 = segment.crop(x1=(segment.w/2),width = (segment.w/2))
  
              background1 = background1.set_position(("left",'center')).fl_image( blur )
              background2 = background2.set_position(("right",'center')).fl_image( blur )
              segment = CompositeVideoClip([background1,background2,segment], size=(replace_width,replace_height))
              segment.effects = self.effects
              
          #############################################################################################
          
          if segment.w != replace_width and segment.h != replace_height:
            segment = segment.resize((replace_width,replace_height))
            #print("On Aspect, too big or small")
  
  
          return segment
code_tokens: def crop_scale ( self , dimensions : Tuple [ int , int ] ) -> 'Segment' : segment = self . copy ( ) dimensions = Dimensions ( * dimensions ) def blur ( image ) : return cv2 . blur ( image . astype ( float ) , ( 30 , 30 ) , 0 ) replace_width = dimensions . width replace_height = dimensions . height if segment . aspect_ratio != replace_width / replace_height : if segment . aspect_ratio <= 1 : if segment . size [ 0 ] != replace_width : segment = segment . resize ( width = replace_width ) if segment . size [ 1 ] != replace_height : segment = segment . resize ( height = replace_height ) segment = segment . set_position ( "center" ) background1 = segment . crop ( x1 = 0 , width = ( segment . w / 2 ) ) background2 = segment . crop ( x1 = ( segment . w / 2 ) , width = ( segment . w / 2 ) ) if segment . aspect_ratio != 1 : background1 = background1 . resize ( width = ( replace_width - segment . w ) / 2 ) background2 = background2 . resize ( width = ( ( replace_width - segment . w ) / 2 ) + 1 ) background1 = background1 . set_position ( ( "left" , 'center' ) ) . fl_image ( blur ) background2 = background2 . set_position ( ( "right" , 'center' ) ) . fl_image ( blur ) segment = CompositeVideoClip ( [ background1 , background2 , segment ] , size = ( replace_width , replace_height ) ) segment . effects = self . effects elif segment . aspect_ratio > round ( replace_width / replace_height , 2 ) : if segment . size [ 1 ] != replace_height : segment = segment . resize ( height = replace_height ) if segment . size [ 0 ] != replace_width : segment = segment . resize ( width = replace_width ) test = ( replace_height - segment . h ) / 2 segment = segment . set_position ( "center" ) background1 = segment . crop ( y1 = 0 , height = ( ( replace_height - segment . h ) / 2 ) ) background2 = segment . crop ( y1 = segment . h - test , height = test ) background1 = background1 . set_position ( ( 'center' , 'top' ) ) . fl_image ( blur ) background2 = background2 . set_position ( ( 'center' , 'bottom' ) ) . fl_image ( blur ) segment = CompositeVideoClip ( [ background1 , background2 , segment ] , size = ( replace_width , replace_height ) ) segment . effects = self . effects elif segment . aspect_ratio > 1 and segment . aspect_ratio < round ( replace_width / replace_height , 2 ) : if segment . size [ 0 ] != replace_width : segment = segment . resize ( width = replace_width ) if segment . size [ 1 ] != replace_height : segment = segment . resize ( height = replace_height ) segment = segment . set_position ( "center" ) background1 = segment . crop ( x1 = 0 , width = ( segment . w / 2 ) ) background2 = segment . crop ( x1 = ( segment . w / 2 ) , width = ( segment . w / 2 ) ) background1 = background1 . set_position ( ( "left" , 'center' ) ) . fl_image ( blur ) background2 = background2 . set_position ( ( "right" , 'center' ) ) . fl_image ( blur ) segment = CompositeVideoClip ( [ background1 , background2 , segment ] , size = ( replace_width , replace_height ) ) segment . effects = self . effects if segment . w != replace_width and segment . h != replace_height : segment = segment . resize ( ( replace_width , replace_height ) ) return segment
short_docstring: Returns
  A new Segment, cropped and/or scaled as necessary to reach specified dimensions
short_docstring_tokens: Returns A new Segment cropped and / or scaled as necessary to reach specified dimensions
comment: """
          Returns
          -------
          A new Segment, cropped and/or scaled as necessary to reach specified dimensions
          """$SEP$#return cv2.GaussianBlur(image.astype(float),(99,99),0)$SEP$#if segment.aspect_ratio != dimensions.aspect_ratio:$SEP$# Crop segment to match aspect ratio$SEP$#segment = segment.crop_to_aspect_ratio(dimensions.aspect_ratio)$SEP$#if segment.dimensions != dimensions:$SEP$# Resize segment to reach final dimensions$SEP$#segment = segment.resize(dimensions)$SEP$##########################################Below 1 AR##################################################$SEP$#print("below 1")$SEP$#print("Not 1:1")$SEP$#########################################Above 1080 ratio###############################################$SEP$#print("above 1.7")$SEP$######################################other#######################################################$SEP$#print('midway between')$SEP$#############################################################################################$SEP$#print("On Aspect, too big or small")