48 lines
888 B
Python
48 lines
888 B
Python
#
|
|
#
|
|
#
|
|
from PIL import Image
|
|
from libs.jpg_bin import JpgBin
|
|
|
|
|
|
class JpgTools:
|
|
|
|
fh = None
|
|
|
|
def __init__(self):
|
|
pass
|
|
|
|
def getJpgBin(self, fname):
|
|
self.processFile(fname)
|
|
|
|
#
|
|
def jpgHash(self):
|
|
pass
|
|
|
|
#
|
|
def getBytes(self, fname):
|
|
if (not self.fh):
|
|
self.fh = open(fname, "rb")
|
|
self.data_buf = self.fh.read(self.BUF_CHUNK_SIZE)
|
|
|
|
#
|
|
def processFile(self, fname):
|
|
self.fh = open(fname, "rb")
|
|
self.jpg = JpgBin()
|
|
retval = self.jpg.processFile(self.fh)
|
|
print("processFile()=={}".format(retval))
|
|
|
|
#
|
|
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.???
|
|
|