diff --git a/libs/jpg_bin.py b/libs/jpg_bin.py index a6fbd23..70fe73b 100644 --- a/libs/jpg_bin.py +++ b/libs/jpg_bin.py @@ -144,6 +144,7 @@ class JpgBin: def markerAppData(self, marker_hex): self.__addPrevMarkerData(marker_hex, "APP ", False) rec_len = self.__calcSeekBytes() + logging.info("length=={}".format(str(rec_len))) # def markerComment(self, marker_hex): @@ -156,19 +157,23 @@ class JpgBin: # def markerSOS(self, marker_hex): self.__addPrevMarkerData(marker_hex, "SOS ") + self.data_idx += 2 + # def markerRST(self, marker_hex): self.__addPrevMarkerData(marker_hex, "RST ") + self.data_idx += 2 # def markerDQT(self, marker_hex): - rec_len = self.__calcSeekBytes() self.__addPrevMarkerData(marker_hex, "DQT ") + rec_len = self.__calcSeekBytes() # def markerDRI(self, marker_hex): self.__addPrevMarkerData(marker_hex, "DRI ") + self.data_idx += 4 # def markerSOF0(self, marker_hex): @@ -188,6 +193,7 @@ class JpgBin: def markerEOI(self, marker_hex): self.__addPrevMarkerData(marker_hex, "EOI ") self.__addPrevMarkerData(marker_hex, "JUST A DUMMY VALUE") + self.data_idx += 2 # private helper function @@ -204,7 +210,6 @@ class JpgBin: self.prev_mhex = mhex self.prev_mstr = mstr self.prev_fpos = cur_fpos - self.data_idx += 2 self.prev_imgData = imgData # diff --git a/libs/jpg_bin_w.py b/libs/jpg_bin_w.py index 731214a..77686be 100644 --- a/libs/jpg_bin_w.py +++ b/libs/jpg_bin_w.py @@ -3,9 +3,9 @@ # class JpgBinWrite: - soi_marker = 0xffd8 - eof_marker = 0xffd9 - picseal_marker = 0xffe0 + soi_marker = b'\xff\xd8' + eof_marker = b'\xff\xd9' + picseal_marker = b'\xff\xe0' # def __init__(self, jpg_in, jpg_out): @@ -49,6 +49,7 @@ class JpgBinWrite: self.fhr.seek(marker.fpos) data = self.fhr.read(marker.len) self.fhw.write(data) + self.fhw.flush() # # array of the marker information @@ -62,6 +63,7 @@ class JpgBinWrite: data = self.fhr.read(marker.len) self.fhw.write(data) + self.fhw.flush() # def __writeJpgHeader(self): diff --git a/picseal.py b/picseal.py index 1c1c11f..2bdab4c 100644 --- a/picseal.py +++ b/picseal.py @@ -20,14 +20,14 @@ def main(): # create new pub keys, sign hash # export signature & public key to a new image file def processImage(image_fn): - jpg = JpgProc() - jpg.process(image_fn) - jpg.hash() + jpg_proc = JpgProc() + jpg_proc.process(image_fn) + jpg_proc.hash() if (write_picseal): print("Writing PicSeal JPG files...") - jpg.writePicSealJpg() + jpg_proc.writePicSealJpg() - printImageInfo(jpg) + printImageInfo(jpg_proc.jpg) # def printImageInfo(jpg_bin):