def resize_string_keeping_height_ratio(string, width, output_format=None, resizemode=Image.ANTIALIAS): if not Strings.is_string(string): return string image = Images.get_image_from_string(string) if output_format is None: output_format = image.format image = Images.resize_image_keeping_height_ratio(image, width) return Images.get_string_from_image(image, output_format)