def pad_image(img, padding_image_height, padding_image_width):
 src_width = img.size[0]
 src_height = img.size[1]
 if (padding_image_width < src_width):
  raise ValueError(('Source image width %d is greater than padding width %d' % (src_width, padding_image_width)))
 if (padding_image_height < src_height):
  raise ValueError(('Source image height %d is greater than padding height %d' % (src_height, padding_image_height)))
 padded_img = PIL.Image.new(img.mode, (padding_image_width, padding_image_height), 'black')
 padded_img.paste(img, (0, 0))
 return padded_img

def pad_image ( img , padding_image_height , padding_image_width ) : src_width = img . size [ 0 ] src_height = img . size [ 1 ] if ( padding_image_width < src_width ) : raise ValueError ( ( 'Source image width %d is greater than padding width %d' % ( src_width , padding_image_width ) ) ) if ( padding_image_height < src_height ) : raise ValueError ( ( 'Source image height %d is greater than padding height %d' % ( src_height , padding_image_height ) ) ) padded_img = PIL . Image . new ( img . mode , ( padding_image_width , padding_image_height ) , 'black' ) padded_img . paste ( img , ( 0 , 0 ) ) return padded_img
pad a single image to the specified dimensions .