from shutil import move

import piexif
from PIL import Image


def delete_metadata(full_path_to_img):
    """
    This function used for remove metadata only from documents, if you send image 'as image' Telegram automatically
    removes all metadata at sending. This function removes all metadata via 'piexif' lib, saved image in '/app'
    folder, and after that move it to 'documents' folder.
    :param full_path_to_img: path to folder with documents e.g.'documents/image.jpg'
    """
    piexif.remove(full_path_to_img, "clean_image.jpg")
    move("clean_image.jpg", "documents/clean_image.jpg")


def delete_metadata_from_png(full_path_to_img):
    """
    This function used for remove metadata only from png documents, if you send image 'as image' Telegram
    automatically removes all metadata at sending. This function removes all metadata via 'PIL' lib and saved image
    in 'documents' folder.
    :param full_path_to_img: path to folder with documents e.g.'documents/image.png'
    """
    image = Image.open(full_path_to_img)
    image.save("documents/clean_image.png")

[(14, 'piexif.remove', 'piexif.remove', False, 'import piexif\n'), (15, 'shutil.move', 'move', False, 'from shutil import move\n'), (25, 'PIL.Image.open', 'Image.open', False, 'from PIL import Image\n')]