add image input
This commit is contained in:
parent
635746d353
commit
b92fad0063
2 changed files with 10 additions and 17 deletions
BIN
image.jpg
Normal file
BIN
image.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
27
pingplace.py
27
pingplace.py
|
@ -1,5 +1,5 @@
|
|||
from icmplib import *
|
||||
from time import sleep
|
||||
from PIL import Image
|
||||
|
||||
def one_ping(socket, address):
|
||||
request = ICMPRequest(
|
||||
|
@ -28,38 +28,31 @@ x=0
|
|||
y=0
|
||||
width=512
|
||||
hight=512
|
||||
r=0
|
||||
g=0
|
||||
b=0
|
||||
prefix="2a01:4f8:c012:f8e6:1"
|
||||
|
||||
# open socket
|
||||
sock = ICMPv6Socket()
|
||||
|
||||
# open image
|
||||
with Image.open("image.jpg") as imgraw:
|
||||
img = imgraw.resize((width, hight))
|
||||
|
||||
# generate IP list
|
||||
ips=[]
|
||||
for w in range(width):
|
||||
if (r>=255):
|
||||
if (g>=255):
|
||||
if(b>=255):
|
||||
r=0
|
||||
g=0
|
||||
b=0
|
||||
else:
|
||||
b=b+1
|
||||
else:
|
||||
g=g+1
|
||||
else:
|
||||
r=r+1
|
||||
for h in range(hight):
|
||||
xcoord=x+w
|
||||
xcoord=f"{xcoord:#05x}".split('x')[-1]
|
||||
ycoord=hex(y+h).split('x')[-1]
|
||||
r=img.getpixel((x+w, y+h))[0]
|
||||
g=img.getpixel((x+w, y+h))[1]
|
||||
b=img.getpixel((x+w, y+h))[2]
|
||||
colorr=f"{r:#04x}".split('x')[-1]
|
||||
colorg=f"{g:#04x}".split('x')[-1]
|
||||
colorb=f"{b:#04x}".split('x')[-1]
|
||||
ip=prefix+xcoord+":"+ycoord+":"+colorr+":"+colorg+colorb
|
||||
ips.append(ip)
|
||||
for ip in ips:
|
||||
one_ping(sock, ip)
|
||||
print(ip)
|
||||
# #one_ping(sock, ip)
|
||||
print("done with %s ips" % len(ips))
|
Loading…
Reference in a new issue