LoginSignup
0
1

More than 3 years have passed since last update.

画像から情報(Exif,GPSなど)を削除する

Posted at

iPhoneで撮影した写真をQiitaにアップする際に、念のためExif,GPSなどの情報を削除しておきます。

情報削除を行うコード

PythonでPillowを使用して、画像を貼り付けて保存する。

reimage.py
from PIL import Image
import argparse


def conv(image_path: str, new_name: str):
    print(f"convert: {image_path} -> {new_name}")
    new_im = None
    with Image.open(image_path) as im:
        new_im = Image.new("RGBA", im.size, (255, 255, 255, 0))
        new_im.paste(im)
    new_im.save(new_name, "png")


parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input")
parser.add_argument("-o", "--output")
args = parser.parse_args()

output = args.input
if args.output:
    output = args.output
conv(args.input, output)

実行コマンド

python3 reimage.py -i 画像パス (-o 新しい画像パス、無ければ元画像に上書き)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1