CoolFace
Datasetpublic

introvoyz041/Tensor-Network-Hackathon-2024

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes5downloads
image_handling.py28 linesDownload Raw Back to qft_compression
1"""2Example to read and write a png file with python3"""4 5import os6import numpy as np7from PIL import Image8 9if __name__ == "__main__":10    filename = "image_compression.png"11 12    # Load image13    if os.path.isfile(filename):14        image = Image.open(filename)15    else:16        raise IOError(f"File {filename} is not present.")17 18    # Convert image to numpy array19    original = np.array(image)20 21    # Here you would do the modifications to the image22 23    # Get PIL image from numpy array24    image = Image.fromarray(original)25 26    # Save image27    image.save(filename)28