WIP: hashing the proper parts of the jpg image

This commit is contained in:
JohnE 2016-10-07 15:39:31 -07:00
parent ed28d01437
commit e0d7466730
2 changed files with 13 additions and 23 deletions

View File

@ -16,7 +16,11 @@ class JpgTools:
# process a jpg file, read only
#
def getJpgBin(self, fname):
return self.processFile(fname)
self.fh = open(fname, "rb")
self.jpg = JpgBin()
retval = self.jpg.processFile(self.fh)
logging.info("processFile()=={}".format(retval))
return self.jpg
#
# process a jpg file, create new jpg with crypto keys
@ -27,24 +31,3 @@ class JpgTools:
retval = self.jpg.processFile(self.fh)
logging.info("processFile()=={}".format(retval))
#
def processFile(self, fname):
self.fh = open(fname, "rb")
self.jpg = JpgBin()
retval = self.jpg.processFile(self.fh)
logging.info("processFile()=={}".format(retval))
return self.jpg
#
def process_OLD(self, fname):
Image.open(fname)
# image as a sequence object containing pixel values
bin_data = list( im.getdata() )
# returns a string containing pixel data, using the standard "raw" encoder
im.tostring()
#
# def getJpgBin_OLD(self, fname):
# img_h = Image.open(fname)
# img_h.???

View File

@ -10,6 +10,7 @@ from libs.crypto_pub import Signature
from libs.toolbox import Toolbox
from libs.jpg_tools import JpgTools
fingerprint = False
def main():
parseArgs()
@ -21,7 +22,9 @@ def main():
def processImage(image_fn):
jpg = JpgTools()
jpg_bin = jpg.getJpgBin(image_fn)
print( str(jpg_bin) )
if (fingerprint):
print( str(jpg_bin) )
# sig = Signature()
# sig.genSig(img_bin)
@ -66,6 +69,7 @@ def parseArgs():
parser.add_argument('-v', '--verbose', action='store_true', help="will set logging level to INFO")
parser.add_argument('-vv', '--vverbose', action='store_true', help="will set logging level to DEBUG")
parser.add_argument('-l', '--logging', action='store_true', help="will supercede the -v option and send all logging to a file, logging.DEBUG")
parser.add_argument('-fp', '--fingerprint', action='store_true', help="fingerprint")
args = parser.parse_args()
if (args.logging):
@ -78,6 +82,9 @@ def parseArgs():
else:
logging.basicConfig(level=logging.CRITICAL)
if (args.fingerprint):
fingerprint = True
if (args.image):
processImage(args.image)
else: