You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
727 B
25 lines
727 B
from PIL import Image
|
|
|
|
|
|
# pip install Pillow
|
|
|
|
# 获取png的exif信息
|
|
def getExif(img):
|
|
with Image.open(img, mode='r', formats=['PNG']) as im:
|
|
fields_to_keep = ('transparency',)
|
|
exif_fields = list(im.info.keys())
|
|
for k in exif_fields:
|
|
if k not in fields_to_keep:
|
|
print(im.info[k])
|
|
|
|
|
|
# 清除png的exif信息
|
|
def clearExif(source, target):
|
|
with Image.open(source, mode='r', formats=['PNG']) as im:
|
|
fields_to_keep = ('transparency',)
|
|
exif_fields = list(im.info.keys())
|
|
for k in exif_fields:
|
|
if k not in fields_to_keep:
|
|
del im.info[k]
|
|
im.save(target, format='PNG')
|
|
# pip install piexif |