MOD: working on writing the jpg files

This commit is contained in:
JohnE 2016-10-12 18:06:36 -07:00
parent 79e35190a8
commit f397467af9
6 changed files with 46 additions and 25 deletions

View File

@ -1,5 +1,5 @@
#
#
# This Class handles the binary parsing of a jpg file
#
#
# 0xFF,0xD8 - Start of Image (0xFFD8FF to be used as JPG file marker)
@ -258,13 +258,3 @@ class JpgBin:
def __repr__(self):
return repr(self.jpg_fp)
#
def findMarkers222(self):
last_idx = len(self.data_buf)
while ord(self.data_buf[self.data_idx]) != 0xFF:
self.data_idx = self.data_idx+1
for idx in range(last_idx):
pass

24
libs/jpg_bin_w.py Normal file
View File

@ -0,0 +1,24 @@
#
#
#
class JpgBinWrite:
soi = 0xffd8
def __init__(self):
pass
def writeJpgPicSeal(self):
pass
def writeJpgMetadata(self):
pass
#
def writeJpgImgData(self):
pass

View File

@ -1,5 +1,5 @@
#
#
# This Class contains information for the jpg markers, length, an position in the file
#
class JpgFingerprint:
@ -55,7 +55,7 @@ class JpgMarker:
self.hex = mhex
self.hexstr = self.hex.to_bytes(2, 'big').hex()
self.fpos = fpos
self.len = mlen
self.len = mlen
self.type = mstr

View File

@ -8,18 +8,15 @@
class JpgPicSeal:
def __init_(self):
self.pubkey = None
self.pvtkey = None
self.imghash = None
self.imgsig = None
self.sig = None
pass
#
def writePicSealJpg(self, fname):
def serilize(self, fname):
pass
#
def readPicSealJpg(self, fname):
def deserialize(self, fname):
pass

View File

@ -7,10 +7,11 @@ from libs.jpg_bin import JpgBin
from libs.crypto_pub import Signature
class JpgTools:
class JpgProc:
def __init__(self):
self.fh = None
self.fn = ""
self.jpg = None
self.sig = None
self.is_processed = False
@ -18,8 +19,9 @@ class JpgTools:
#
# process a jpg file, read only
#
def getJpgBin(self, fname):
def jpgProc(self, fname):
self.fh = open(fname, "rb")
self.fn = fname
self.jpg = JpgBin()
retval = self.jpg.processFile(self.fh)
logging.info("processFile()=={}".format(retval))
@ -31,10 +33,18 @@ class JpgTools:
#
def jpgHash(self):
if (not self.is_processed):
self.getJpgBin(fname)
return 0xdeadbeef
# hash the jpg image data
self.sig = Signature()
img_hash = self.jpg.genHash(self.sig.hh)
logging.info("img_hash-size=={}, img_hash=={}".format(len(img_hash), img_hash))
return img_hash
def writePicSealJpg(self, fname=None):
if not fname:
pass
pass

View File

@ -7,7 +7,7 @@ import logging
from shutil import copyfile
#from subprocess import Popen, PIPE, check_call
from libs.toolbox import Toolbox
from libs.jpg_tools import JpgTools
from libs.jpg_proc import JpgProc
printall = False
printmeta = False
@ -22,8 +22,8 @@ def main():
# create new pub keys, sign hash
# export signature & public key to a new image file
def processImage(image_fn):
jpg = JpgTools()
jpg_bin = jpg.getJpgBin(image_fn)
jpg = JpgProc()
jpg.getProc(image_fn)
img_hash = jpg.jpgHash()
printImageInfo(jpg_bin)