def convert_image(from_file, to_file, image_format):
    """Convert an image to given format."""
    with Image(filename=from_file) as original:
        with original.convert(image_format) as converted:
            converted.save(filename=to_file)
    return to_file
def convert_image ( from_file , to_file , image_format ) : with Image ( filename = from_file ) as original : with original . convert ( image_format ) as converted : converted . save ( filename = to_file ) return to_file
Convert an image to given format.