Hidden confession skills, python teaches you how to use picture exif information to hide confession, teach you how to modify and query exif information.

"  Hidden confession skills "

Have you ever thought about the information contained in a picture? Have you ever thought that a picture can hide some content for you? Have you ever thought that the hidden information of the picture can express what you want to explain for you? And you can use pictures to express your love. Come, let's learn quickly.

 

01— Analysis of ideas

The first step: first understand what we are going to do?

What do we want to do, we want to express our love hidden in the picture, and let the other party have to obtain this information in some way.

 

Then the question arises, how do we do it. First of all, we wrote in the last article that all the pictures obtained through the camera have exif, click the link below to enter.

 

A photo of hackers may reveal your basic information

 

Well, if there is an idea, it will be perfect, let's continue to look at it.

 

Step 2: How can we hide information?

We can already get the hidden information of the picture through python, can we modify the exif information of the picture? Of course the answer is yes, so we found

piexif

This module can help us modify the exif information. Let you hide the content you need.

 

02— write code

 

Know how to achieve, then let's see how to achieve this requirement.

 

code show as below:

from PIL import Image
import piexif
import exifread
​
​
img = Image.open("0627.jpg")
exif_message = piexif.load(img.info["exif"])
​
for ifd in ("0th", "Exif", "GPS", "1st"):#循环打印修改之前图片exif信息
    for tag in exif_message[ifd]:
        print(piexif.TAGS[ifd][tag], exif_message[ifd][tag])
exif_message["0th"][piexif.ImageIFD.Artist] = "我想大声告诉你我喜欢你".encode()#这里是作者名,我们写上自己想要的话
exif_message["Exif"][piexif.ExifIFD.DateTimeOriginal] = '2020:05:20 13:14:20'.encode()#修改一个时间都是爱你的模样
exif_message["GPS"][piexif.GPSIFD.GPSLatitude] = ((23, 1), (9, 1), (7628174, 1000000))#修改纬度
exif_message["GPS"][piexif.GPSIFD.GPSLongitude] = ((108, 1), (9, 1), (7628174, 1000000))#修改经度
exif_bytes = piexif.dump(exif_message)
img.save("0627.jpg", exif=exif_bytes)#保存修改之后的图片
​
print('------------------------------修改后-----------------------------------')
for ifd in ("0th", "Exif", "GPS", "1st"):
    for tag in exif_message[ifd]:
        print(piexif.TAGS[ifd][tag], exif_message[ifd][tag])
​
img.close()
​
print("--------读取经纬度信息,并计算位置-------")
​
f = open("0627.jpg", 'rb+')
​
tags = exifread.process_file(f)
​
lat = str(tags.get('GPS GPSLatitude', '0')).split("[")[1].split("]")[0].split(",")
​
print("纬度为:",float(lat[0])+float(lat[1])/60+float(lat[2].split("/")[0])/float(lat[2].split("/")[1])/3600)
​
long= str(tags.get('GPS GPSLongitude', '0')).split("[")[1].split("]")[0].split(",")
​
print("经度为:",float(long[0])+float(long[1])/60+float(long[2].split("/")[0])/float(long[2].split("/")[1])/3600)

 

 

03— write code

 

Here I focused on how to modify the latitude and longitude. For other data that needs to be modified, you can follow the official account for inquiries.

The main information can be viewed by clicking the right button of the picture and viewing the properties.​ As shown in the figure​:

 

 

​Is it amazing? In addition, here I have told you how to modify the latitude and longitude. It cannot be modified by the above method, but can only be modified by code. In this way, you can add different latitude and longitude to the picture. When we connect certain points on the map by latitude and longitude, some wonderful changes will occur.

​For example: You can draw a heart on the map​. Write a simple sentence in English ​love you​.

You can even draw a picture for her (him) through coordinates​.

 

 

Related recommendations​:

Say goodbye to drop-down, easily operate excel

A photo of hackers may reveal your location

520 beautiful confession tree, let her (him) feel your tenderness

520 Give her your exclusive chat tool

 

Learn more, welcome to follow us!

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_39046854/article/details/106162956