parameters: (self, input_file, output_file, output_side_length = 256)
docstring: Takes an image name, resize it and crop the center square
docstring_summary: Takes an image name, resize it and crop the center square
docstring_tokens: Takes an image name resize it and crop the center square
function: def resize_and_crop_image(self, input_file, output_file, output_side_length = 256):
          '''Takes an image name, resize it and crop the center square
          '''
          img = cv2.imread(input_file)
          height, width, depth = img.shape
          new_height = output_side_length
          new_width = output_side_length
          if height > width:
              new_height = output_side_length * height / width
          else:
              new_width = output_side_length * width / height
          resized_img = cv2.resize(img, (new_width, new_height))
          height_offset = (new_height - output_side_length) / 2
          width_offset = (new_width - output_side_length) / 2
          cropped_img = resized_img[height_offset:height_offset + output_side_length,
                                    width_offset:width_offset + output_side_length]
          cv2.imwrite(output_file, cropped_img)
function_tokens: def resize_and_crop_image ( self , input_file , output_file , output_side_length = 256 ) : img = cv2 . imread ( input_file ) height , width , depth = img . shape new_height = output_side_length new_width = output_side_length if height > width : new_height = output_side_length * height / width else : new_width = output_side_length * width / height resized_img = cv2 . resize ( img , ( new_width , new_height ) ) height_offset = ( new_height - output_side_length ) / 2 width_offset = ( new_width - output_side_length ) / 2 cropped_img = resized_img [ height_offset : height_offset + output_side_length , width_offset : width_offset + output_side_length ] cv2 . imwrite ( output_file , cropped_img )