From 1fea208349fcc3128efc06472d3ae177c6ac64a8 Mon Sep 17 00:00:00 2001 From: JohnE Date: Thu, 1 Dec 2016 00:17:05 -0800 Subject: [PATCH] WIP: working on the reading of picseal image files --- libs/jpg_bin.py | 9 ++++++++- libs/jpg_bin_w.py | 17 +++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libs/jpg_bin.py b/libs/jpg_bin.py index ee368e8..e071c30 100644 --- a/libs/jpg_bin.py +++ b/libs/jpg_bin.py @@ -25,7 +25,14 @@ from libs.jpg_fp import JpgFingerprint # class JpgBin: - BUF_CHUNK_SIZE = 2048 + BUF_CHUNK_SIZE = 8192 + + soi_marker = b'\xff\xd8' + eof_marker = b'\xff\xd9' + app15_marker = b'\xff\xef' + # ascii code for "picseal" + picseal_marker = b'\x70\x69\x63\x73\x65\x61\x6C' + def __init__(self): self.data_buf = None diff --git a/libs/jpg_bin_w.py b/libs/jpg_bin_w.py index 9ef88c3..f62b17e 100644 --- a/libs/jpg_bin_w.py +++ b/libs/jpg_bin_w.py @@ -1,13 +1,12 @@ # # # +from libs.jpg_bin import JpgBin + + class JpgBinWrite: - soi_marker = b'\xff\xd8' - eof_marker = b'\xff\xd9' - picseal_marker = b'\xff\xef' - # picseal_marker = b'\xff\xe0' - + # def __init__(self, jpg_in, jpg_out): self.fhr = jpg_in @@ -41,8 +40,10 @@ class JpgBinWrite: size += len(crypto_sig.hash_data) size += len(keyder) + # write app marker + self.fhw.write(JpgBin.app15_marker) # write picseal marker - self.fhw.write(JpgBinWrite.picseal_marker) + self.fhw.write(JpgBin.picseal_marker) # write the size of picseal record self.fhw.write(size.to_bytes(2, byteorder='big')) # write hash of image @@ -84,8 +85,8 @@ class JpgBinWrite: # def __writeJpgHeader(self): - self.fhw.write(bytes(JpgBinWrite.soi_marker)) + self.fhw.write(bytes(JpgBin.soi_marker)) # def __writeJpgFooter(self): - self.fhw.write(bytes(JpgBinWrite.eof_marker)) + self.fhw.write(bytes(JpgBin.eof_marker))