#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2025/12/26 00:20:42 +0900> """ Convert png to base64 Usage : python png2base64.py Windows11 x64 25H2 + Python 3.10.10 64bit """ import base64 FILENAME = "input.png" def image_to_base64(file_path): try: with open(file_path, "rb") as image_file: encoded_string = base64.b64encode(image_file.read()).decode("utf-8") return encoded_string except FileNotFoundError: return f"Error: Not found {file_path}" if __name__ == "__main__": result = image_to_base64(FILENAME) print(result)