Pad images
- plot_utils.pad_img(files, target_aspect_ratio=1.0, pad_color='white', inplace=False, verbose=True, show_old_img=False, show_new_img=False, forcibly_overwrite=False, resize=False, new_width_height=(640, 480))[source]
Pad empty edges to images so that they meet the target aspect ratio (i.e., more square).
- Parameters:
files (str or list<str> or tuple<str>) – A file name (as Python str) or several file names (as Python list or tuple) to be padded.
target_aspect_ratio (float) – The target aspect ratio to convert the original image into. A value between 0 (exclusive) and 1 (inclusive).
pad_color (str or tuple<float> or list<float>) – The color of the padded margin. Valid
pad_color
values are color names recognizable by matplotlib: https://matplotlib.org/tutorials/colors/colors.htmlinplace (bool) – Whether or not to replace the existing figure file with the padded content.
verbose (bool) – Whether or not to print the progress onto the console.
show_old_img (bool) – Whether or not to show the old figure in the console.
show_new_img (bool) – Whether or not to show the padded figure in the console.
forcibly_overwrite (bool) – Whether or not to overwrite an image on the hard drive with the same name. Only applicable when
inplace
isFalse
.resize (bool) – Whether to resize the padded image
new_width_height ((int, int)) – The new image width and height. It has no effect if
resize` is false, and there will be an error if the provided aspect ratio doesn't match ``target_aspect_ratio
.