python

# -*- coding: utf-8 -*-
import base64

# 保存ファイル名を設定(拡張子を含まない)
output_file_name = 'output_base64'

# pngファイルのパスを指定
png_file_path = 'image.png'  # png_file_path = 'path/to/your/image.png'

# pngファイルをバイナリモードで読み込む
with open(png_file_path, 'rb') as png_file:
    # バイナリデータをBase64エンコードする
    base64_encoded_data = base64.b64encode(png_file.read())

# Base64エンコードされたデータをテキストファイルに書き込む
# ファイルをBOMなしで保存する
with open(f'{output_file_name}.txt', 'wb') as output_file:
    output_file.write(base64_encoded_data)