0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python で 画像のGPS 情報を削除する方法

Last updated at Posted at 2017-08-07

python3 で、GPS 情報 (exif) を削除する方法です。
piexif を使います。

Arch Linux でのインストール方法

sudo pacman -S python-piexif

削除して、同じ名前で保存する場合

remove01.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#
import piexif
import sys
#
jpg_file = sys.argv[1]
piexif.remove(jpg_file)
#

削除して別名で保存する場合

remove02.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#
import piexif
import io
import sys
#
jpg_in=sys.argv[1]
jpg_out=sys.argv[2]
#
fp_in=open(jpg_in,"rb")
data_in=fp_in.read()
fp_in.close()
#
output = io.BytesIO()
piexif.remove(data_in,output)
image_jpg = output.getvalue()
#
fp_out=open(jpg_out,"wb")
fp_out.write(image_jpg)
fp_out.close()
#

Exif の確認方法

jhead sample.jpg

Arch Linux で jhead のインストール方法

sudo pacman -S jhead

コマンドで、Exif を削除する方法

jhead -purejpg sample.jpg
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?