def show(self, columSize: int = 10, linesHalt: int = -1):
     txt1 = '\tApp Marker       : ' + self.s0_app_marker.hex(
         sep=' ') + "  '" + Kind.findType(
             self.s0_app_marker).shortname + "'"
     txt2 = '\tApp Length       : ' + self.s1_app_length.hex(
         sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
     print(txt1)
     print(txt2)
     print("")
     s2hex(dataBytes=self.s2_all_data,
           dataName=Kind.findType(self.s0_app_marker).shortname,
           columnSize=columSize,
           linesHalt=linesHalt)
예제 #2
0
 def __init__(self, item:object=None):
     if item == None:
         self.no = 0
         self.root = 0
         self.start = 0
         self.end = 0
         self.applistno = -1
         self.type = Kind()
     else:
         self.no = item.no
         self.root = item.root
         self.start = item.start
         self.end = item.end
         self.applistno = item.applistno
         self.type = Kind(item=item.type)
    def showAll(self):
        txt1_format = "\t{:<21} : '{}'   {}"
        txt1_tmp1 = "(-" + Kind.findType(
            bytesData=self.s0_app_marker).shortname + "-)"
        txt1 = txt1_format.format('App Marker',
                                  self.s0_app_marker.hex(sep=' '), txt1_tmp1)
        txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)'
        txt2 = txt1_format.format('App Length',
                                  self.s1_app_length.hex(sep=' '), txt2_tmp1)
        txt3 = txt1_format.format('JFXX Marker',
                                  self.s2_jfxx_marker.hex(sep=' '),
                                  "'JFXX\\x00'")

        if self.s3_jfxx_thumbnail_format == b'10':
            txt4_tmp1 = '(-JPEG format-)'
        elif self.s3_jfxx_thumbnail_format == b'11':
            txt4_tmp1 = '(-1 byte per pixel palettized format-)'
        elif self.s3_jfxx_thumbnail_format == b'13':
            txt4_tmp1 = '(-3 byte per pixel RGB format-)'
        else:
            txt4_tmp1 = '(?)'
        txt4 = txt1_format.format('JFXX Thumbnail Format',
                                  self.s3_jfxx_thumbnail_format.hex(),
                                  txt4_tmp1)

        print(txt1)
        print(txt2)
        print(txt3)
        print(txt4)
        s2hex(dataBytes=self.s4_jfxx_thumbnail_data,
              dataName="'JFXX Thumbnail Data'",
              columnSize=20)
 def show(self):
     txt1 = '\tApp Marker       : ' + self.s0_app_marker.hex(
         sep=' ') + "  '" + Kind.findType(
             self.s0_app_marker).shortname + "'"
     txt2 = '\tApp Length       : ' + self.s1_app_length.hex(
         sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
     txt3 = '\tAdobe_CM Marker  : ' + self.s2_adobe_marker.hex(
         sep=' ') + "  '" + self.s2_adobe_marker_str + "'"
     print(txt1)
     print(txt2)
     print(txt3)
     if len(self.s3_all_data) >= 14:
         txt4 = '\tAdobe_CM Starter : ' + self.s3_all_data[13:14].hex(
             sep=' ')
         print(txt4)
     print()
     s2hex(dataBytes=self.s3_all_data,
           dataName=Kind.findType(self.s0_app_marker).shortname,
           columnSize=20)
예제 #5
0
    def all(self) -> str:
        txt1_format = "\t{:<20} : '{}'   {}"
        txt1_tmp1 = "(-" + Kind.findType(
            bytesData=self.s0_app_marker).shortname + "-)\n"
        txt1 = txt1_format.format('App Marker',
                                  self.s0_app_marker.hex(sep=' '), txt1_tmp1)
        txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)\n'
        txt2 = txt1_format.format('App Length',
                                  self.s1_app_length.hex(sep=' '), txt2_tmp1)
        txt3 = txt1_format.format('JFIF Marker',
                                  self.s2_jfif_marker.hex(sep=' '),
                                  "'JFIF\\x00'\n")
        txt4_tmp1 = self.s3_jfif_version_1_major.hex(
        ) + ' ' + self.s3_jfif_version_2_minor.hex()
        txt4_tmp2 = '(' + str(ord(self.s3_jfif_version_1_major)) + '.' + str(
            ord(self.s3_jfif_version_2_minor)) + ')\n'
        txt4 = txt1_format.format('JFIF Version', txt4_tmp1, txt4_tmp2)
        if self.s4_jfif_density_units.lower() == '00':
            txt5_tmp1 = '(-No Units:::Pixel Aspect Ratio-)\n'
        elif self.s4_jfif_density_units.hex().lower() == '01':
            txt5_tmp1 = '(-Pixels Per Inch [2.54 cm]-)\n'
        elif self.s4_jfif_density_units.hex().lower() == '02':
            txt5_tmp1 = '(-Pixels Per Centimeter-)\n'
        else:
            txt5_tmp1 = '(?)\n'
        txt5 = txt1_format.format('JFIF Density Units',
                                  self.s4_jfif_density_units.hex(), txt5_tmp1)
        txt6 = txt1_format.format('JFIF X Density',
                                  self.s5_jfif_xdensity.hex(sep=' '), '\n')
        txt7 = txt1_format.format('JFIF Y Density',
                                  self.s6_jfif_ydensity.hex(sep=' '), '\n')
        txt8 = txt1_format.format('JFIF X Thumbnail',
                                  self.s7_jfif_xthumbnail.hex(sep=' '), '\n')
        txt9 = txt1_format.format('JFIF Y Thumbnail',
                                  self.s8_jfif_ythumbnail.hex(sep=' '), '\n')

        thumbnail_length = len(self.s9_jfif_thumbnaildata)
        txt2_format = "\t{:<20} : '{}"
        txt10 = ''
        for kk in range(0, thumbnail_length):
            if kk % 10 == 0:
                if kk == 0:
                    txt10 = txt2_format.format(
                        'JFIF Thumbnail Data',
                        self.s9_jfif_thumbnaildata[kk:kk + 1].hex())
                else:
                    txt10 += "'\n" + txt2_format.format(
                        '', self.s9_jfif_thumbnaildata[kk:kk + 1].hex())
            else:
                txt10 += ' ' + self.s9_jfif_thumbnaildata[kk:kk + 1].hex()
            if kk == thumbnail_length - 1:
                txt10 += "'"

        result = txt1 + txt2 + txt3 + txt4 + txt5 + txt6 + txt7 + txt8 + txt9 + txt10
        return result
 def show(self):
     txt1 = '\tApp Marker       : ' + self.s0_app_marker.hex(
         sep=' ') + "  '" + Kind.findType(
             self.s0_app_marker).shortname + "'"
     txt2 = '\tApp Length       : ' + self.s1_app_length.hex(
         sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
     txt3 = '\tAdobe Marker     : ' + self.s2_adobe_marker.hex(
         sep=' ') + "  '" + self.s2_adobe_marker_str + "'"
     print(txt1)
     print(txt2)
     print(txt3)
     if len(self.s3_all_data) >= 12:
         txt4 = '\tAdobe Starter    : ' + self.s3_all_data[10:12].hex(
             sep=' ') + "  '" + self.s3_all_data[10:11].hex(
             ) + " Bit - (" + self.s3_all_data[11:12].hex() + ")'"
         print(txt4)
     if len(self.s3_all_data) >= 16:
         txt5 = '\tAdobe Data       : ' + self.s3_all_data[12:16].hex(
             sep=' ')
         print(txt5)
     print()
     s2hex(dataBytes=self.s3_all_data,
           dataName=Kind.findType(self.s0_app_marker).shortname,
           columnSize=20)
    def showHeader(self):
        txt1 = '\tApp Marker       : ' + self.s0_app_marker.hex(
            sep=' ') + "  '" + Kind.findType(
                self.s0_app_marker).shortname + "'"
        txt2 = '\tApp Length       : ' + self.s1_app_length.hex(
            sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
        txt3 = '\tXMP Marker (Hex) : ' + self.s2_xmp_marker.hex(sep=' ')
        txt4 = '\tXMP Marker (Str) : "' + self.s2_xmp_marker_str + '"'
        txt5 = '\tXMP Encoding     : ' + self.s3_xmp_encoding_str

        print(txt1)
        print(txt2)
        print(txt3)
        print(txt4)
        print(txt5)
예제 #8
0
    def showHeader(self):
        txt1 = '\tApp Marker                             : ' + self.s0_app_marker.hex(
            sep=' ') + "  '" + Kind.findType(
                self.s0_app_marker).shortname + "'"
        txt2 = '\tApp Length                             : ' + self.s1_app_length.hex(
            sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
        txt3 = '\tExif Marker                            : ' + self.s2_exif_marker.hex(
            sep=' ') + "  '" + self.s2_exif_marker_str + "'"
        txt4 = '\tExif Byte Order                        : ' + self.s3_exif_byte_order.hex(
            sep=' ') + "  '" + self.s3_exif_byte_order.decode(
                encoding='Ascii',
                errors='replace') + "'  '" + self.s3_exif_byte_order_str + "'"
        txt5 = '\tExif Version Number                    : ' + self.s4_exif_version_number.hex(
            sep=' ') + "  (" + str(clength(self.s4_exif_version_number)) + ")"
        txt6 = '\tExif IFD                               : ' + self.s5_exif_image_file_directory_ifd.hex(
            sep=' ')
        txt7 = "\tExif 'OIFD' Tags Count                 : " + str(
            len(self.s6_exif_0IFD_3tags))
        txt8 = "\tExif 'Exif IFD' Tags Count             : " + str(
            len(self.s7_exif_ExifIFD_3tags))
        txt9 = "\tExif 'Interoperability IFD' Tags Count : " + str(
            len(self.s8_exif_InterOperability_3tags))
        txt10 = "\tExif 'GPS IFD' Tags Count              : " + str(
            len(self.s9_exif_GpsIFD_3tags))
        txt11 = "\tExif '1IFD' Tags Count                 : " + str(
            len(self.s10_exif_1IFD_3tags))
        txt12 = "\t                                     +           "
        txt13 = "\t                                     ----------- "
        txt14 = "\tExif Total Tags Count                  : " + str(
            len(self.s6_exif_0IFD_3tags) + len(self.s7_exif_ExifIFD_3tags) +
            len(self.s8_exif_InterOperability_3tags) +
            len(self.s9_exif_GpsIFD_3tags) + len(self.s10_exif_1IFD_3tags))

        print(txt1)
        print(txt2)
        print(txt3)
        print(txt4)
        print(txt5)
        print(txt6)
        print()
        print(txt7)
        print(txt8)
        print(txt9)
        print(txt10)
        print(txt11)
        print(txt12)
        print(txt13)
        print(txt14)
예제 #9
0
 def showAll(self):
     txt1_format = "\t{:<20} : '{}'   {}"
     txt1_tmp1 = "(-" + Kind.findType(
         bytesData=self.s0_app_marker).shortname + "-)"
     txt1 = txt1_format.format('App Marker',
                               self.s0_app_marker.hex(sep=' '), txt1_tmp1)
     txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)'
     txt2 = txt1_format.format('App Length',
                               self.s1_app_length.hex(sep=' '), txt2_tmp1)
     txt3 = txt1_format.format('JFIF Marker',
                               self.s2_jfif_marker.hex(sep=' '),
                               "'JFIF\\x00'")
     txt4_tmp1 = self.s3_jfif_version_1_major.hex(
     ) + ' ' + self.s3_jfif_version_2_minor.hex()
     txt4_tmp2 = '(' + str(ord(self.s3_jfif_version_1_major)) + '.' + str(
         ord(self.s3_jfif_version_2_minor)) + ')'
     txt4 = txt1_format.format('JFIF Version', txt4_tmp1, txt4_tmp2)
     if self.s4_jfif_density_units.lower() == '00':
         txt5_tmp1 = '(-No Units:::Pixel Aspect Ratio-)'
     elif self.s4_jfif_density_units.hex().lower() == '01':
         txt5_tmp1 = '(-Pixels Per Inch [2.54 cm]-)'
     elif self.s4_jfif_density_units.hex().lower() == '02':
         txt5_tmp1 = '(-Pixels Per Centimeter-)'
     else:
         txt5_tmp1 = '(?)'
     txt5 = txt1_format.format('JFIF Density Units',
                               self.s4_jfif_density_units.hex(), txt5_tmp1)
     txt6 = txt1_format.format('JFIF X Density',
                               self.s5_jfif_xdensity.hex(sep=' '), '')
     txt7 = txt1_format.format('JFIF Y Density',
                               self.s6_jfif_ydensity.hex(sep=' '), '')
     txt8 = txt1_format.format('JFIF X Thumbnail',
                               self.s7_jfif_xthumbnail.hex(sep=' '), '')
     txt9 = txt1_format.format('JFIF Y Thumbnail',
                               self.s8_jfif_ythumbnail.hex(sep=' '), '')
     print(txt1)
     print(txt2)
     print(txt3)
     print(txt4)
     print(txt5)
     print(txt6)
     print(txt7)
     print(txt8)
     print(txt9)
     s2hex(dataBytes=self.s9_jfif_thumbnaildata,
           dataName="'JFIF Thumbnail Data'",
           columnSize=20)
예제 #10
0
    def showParams(self, columnSize=50, linesHalt=-1):
        txt1 = '\tApp Marker       : ' + self.s0_app_marker.hex(
            sep=' ') + "  '" + Kind.findType(
                self.s0_app_marker).shortname + "'"
        txt2 = '\tApp Length       : ' + self.s1_app_length.hex(
            sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
        txt3 = '\tXMP Marker (Hex) : ' + self.s2_xmp_marker.hex(sep=' ')
        txt4 = '\tXMP Marker (Str) : "' + self.s2_xmp_marker_str + '"'
        txt5 = '\tXMP Encoding     : ' + self.s3_xmp_encoding_str

        print(txt1)
        print(txt2)
        print(txt3)
        print(txt4)
        print(txt5)
        print("")
        #
        if self.s3_xmp_encoding_int == 1:
            sutf8(bytesData=self.s4_xmp_data.replace(
                self.s3_xmp_encoding_bytes, b'0xEF 0xBB 0xBF'),
                  columnSize=columnSize,
                  linesHalt=linesHalt)
        elif self.s3_xmp_encoding_int == 2:
            sutf16be(bytesData=self.s4_xmp_data.replace(
                self.s3_xmp_encoding_bytes, b'0xFE 0xFF'),
                     columnSize=columnSize,
                     linesHalt=linesHalt)
        elif self.s3_xmp_encoding_int == 3:
            sutf16le(bytesData=self.s4_xmp_data.replace(
                self.s3_xmp_encoding_bytes, b'0xFF 0XFE'),
                     columnSize=columnSize,
                     linesHalt=linesHalt)
        elif self.s3_xmp_encoding_int == 4:
            sutf32be(bytesData=self.s4_xmp_data.replace(
                self.s3_xmp_encoding_bytes, b'0x00 0x00 0xFE 0XFF'),
                     columnSize=columnSize,
                     linesHalt=linesHalt)
        elif self.s3_xmp_encoding_int == 5:
            suft32le(bytesData=self.s4_xmp_data.replace(
                self.s3_xmp_encoding_bytes, b'0xFF 0XFE 0x00 0x00'),
                     columnSize=columnSize,
                     linesHalt=linesHalt)
        else:
            print('\tData Encoding Unknown')
 def showHeader(self):
     txt1 = '\tApp Marker                   : ' + self.s0_app_marker.hex(
         sep=' ') + "  '" + Kind.findType(
             self.s0_app_marker).shortname + "'"
     txt2 = '\tApp Length                   : ' + self.s1_app_length.hex(
         sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
     txt3 = '\tPhotoshop Marker (Hex)       : ' + self.s2_photoshop_marker.hex(
         sep=' ')
     txt4 = '\tPhotoshop Marker (Str)       : ' + self.s2_photoshop_marker_str
     txt5 = '\tPhotoshop Tags Count         : ' + str(
         len(self.s3_photoshop_tags))
     txt6 = '\t<<8BIM>4bayt> - <<Tag>2bayt> - <<Padding>2bayt>- <<Count>4bayt> - <<Data>Variable>'
     #
     print(txt1)
     print(txt2)
     print(txt3)
     print(txt4)
     print(txt5)
     print(txt6)
    def all(self) -> str:
        txt1_format = "\t{:<21} : '{}'   {}\n"
        txt1_tmp1 = "(-" + Kind.findType(
            bytesData=self.s0_app_marker).shortname + "-)"
        txt1 = txt1_format.format('App Marker',
                                  self.s0_app_marker.hex(sep=' '), txt1_tmp1)
        txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)'
        txt2 = txt1_format.format('App Length',
                                  self.s1_app_length.hex(sep=' '), txt2_tmp1)
        txt3 = txt1_format.format('JFXX Marker',
                                  self.s2_jfxx_marker.hex(sep=' '),
                                  "'JFXX\\x00'")

        if self.s3_jfxx_thumbnail_format == b'10':
            txt4_tmp1 = '(-JPEG format-)'
        elif self.s3_jfxx_thumbnail_format == b'11':
            txt4_tmp1 = '(-1 byte per pixel palettized format-)'
        elif self.s3_jfxx_thumbnail_format == b'13':
            txt4_tmp1 = '(-3 byte per pixel RGB format-)'
        else:
            txt4_tmp1 = '(?)'
        txt4 = txt1_format.format('JFXX Thumbnail Format',
                                  self.s3_jfxx_thumbnail_format.hex(),
                                  txt4_tmp1)
        thumbnail_length = len(self.s4_jfxx_thumbnail_data)
        txt2_format = "\t{:<21} : '{}"
        txt5 = ''
        for kk in range(0, thumbnail_length):
            if kk % 10 == 0:
                if kk == 0:
                    txt5 = txt2_format.format(
                        'JFIF Thumbnail Data',
                        self.s4_jfxx_thumbnail_data[kk:kk + 1].hex())
                else:
                    txt5 += "'\n" + txt2_format.format(
                        '', self.s4_jfxx_thumbnail_data[kk:kk + 1].hex())
            else:
                txt5 += ' ' + self.s4_jfxx_thumbnail_data[kk:kk + 1].hex()
            if kk == thumbnail_length - 1:
                txt5 += "'"

        result = txt1 + txt2 + txt3 + txt4 + txt5
        return result
예제 #13
0
    def showHeader(self):
        txt1 = '\tApp Marker         : ' + self.s0_app_marker.hex(
            sep=' ') + "  '" + Kind.findType(
                self.s0_app_marker).shortname + "'"
        txt2 = '\tApp Length         : ' + self.s1_app_length.hex(
            sep=' ') + '  (' + str(self.s1_app_length_int) + ' bayt)'
        txt3 = '\tMPF Marker         : ' + self.s2_mpf_marker.hex(
            sep=' ') + "  '" + self.s2_mpf_marker_str + "'"
        txt4 = '\tMPF Byte Order     : ' + self.s3_mpf_byte_order.hex(
            sep=' ') + "  '" + self.s3_mpf_byte_order.decode(
                encoding='utf-8',
                errors='replace') + "'  (-" + self.s3_mpf_byte_order_str + "-)"
        txt5 = '\tMPF Version        : ' + self.s4_mpf_version.hex(sep=' ')
        txt6 = '\tMPF IFD            : ' + self.s5_mpf_IFD.hex(sep=' ')
        txt7 = '\tMPF IFD Tags Count : ' + self.s6_mpf_IFD_tags_count.hex(
            sep=' ') + "  (" + str(self.s6_mpf_IFD_tags_count_int) + ")"

        print(txt1)
        print(txt2)
        print(txt3)
        print(txt4)
        print(txt5)
        print(txt6)
        print(txt7)
예제 #14
0
def findSectors(jpgBytes: bytes) -> List[Sector]:
    #
    jpgSectors_tmp = []
    jpgDataLength = len(jpgBytes)
    checkLength = jpgDataLength - 1
    itemCount = 1
    #

    # 1) SOI 'Start Of Image'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.SOI()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 2) EOI 'End Of Image'    - 2 bayt
    startIndex = 0
    tmp_kind = Kind.EOI()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 3) DRI 'Define Restart Interval'    - 4 bayt
    startIndex = 0
    tmp_kind = Kind.DRI()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 4
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 4
        #
        if startIndex > checkLength:
            break
        #

    # 4) APP0 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP0()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 5) APP1 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP1()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 6) APP2 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP2()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 7) APP3 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP3()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 8) APP4 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP4()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 22

    # 9) APP5 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP5()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 10) APP6 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP6()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 11) APP7 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP7()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 12) APP8 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP8()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 13) APP9 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APP9()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 14) APPA 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPA()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 15) APPB 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPB()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 16) APPC 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPC()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 17) APPD 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPD()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 18) APPE 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPE()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 19) APPF 'Application Specific'
    startIndex = 0
    tmp_kind = Kind.APPF()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 20) SOF0 'Start Of Frame (Baseline DCT)'
    startIndex = 0
    tmp_kind = Kind.SOF0()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 21) SOF2 'Start Of Frame (Progressive DCT)'
    startIndex = 0
    tmp_kind = Kind.SOF2()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 22) DHT 'Define Huffman Table(s)'
    startIndex = 0
    tmp_kind = Kind.DHT()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 23) DQT 'Define Quantization Table(s)'
    startIndex = 0
    tmp_kind = Kind.DQT()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 24) SOS 'Start Of Scan'
    startIndex = 0
    tmp_kind = Kind.SOS()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 25) COM 'Comment'
    startIndex = 0
    tmp_kind = Kind.COM()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        if startIndex + 4 > checkLength:
            break
        applength = appLength(data=jpgBytes[startIndex + 2:startIndex + 4])
        tmp_end = startIndex + 2 + applength
        if applength > -1 and tmp_end < checkLength:
            item = Sector()
            item.no = itemCount
            item.start = startIndex
            item.end = tmp_end
            item.root = 0
            item.type = tmp_kind
            jpgSectors_tmp.append(item)
            #
            itemCount += 1
        #
        startIndex += 2

    # 26) RST0 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST0()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 27) RST1 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST1()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 28) RST2 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST2()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 29) RST3 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST3()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 30) RST4 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST4()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 31) RST5 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST5()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 32) RST6 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST6()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #

    # 33) RST7 'Restart'   - 2 bayt
    startIndex = 0
    tmp_kind = Kind.RST7()
    while True:
        tmp_index = jpgBytes[startIndex:].find(tmp_kind.marker)
        if tmp_index == -1:
            break
        startIndex += tmp_index
        #
        item = Sector()
        item.no = itemCount
        item.start = startIndex
        item.end = startIndex + 2
        item.root = 0
        item.type = tmp_kind
        jpgSectors_tmp.append(item)
        #
        itemCount += 1
        startIndex += 2
        #
        if startIndex > checkLength:
            break
        #
    #
    # Detect Root Child
    jpgSectors = []
    #
    sort_jpgSectors_tmp = sorted(jpgSectors_tmp, key=lambda x: x.start)
    number_find = len(sort_jpgSectors_tmp)
    #
    for ii in range(0, number_find):
        main_item = sort_jpgSectors_tmp[ii]
        if ii > 0:
            for jj in range((ii - 1), -1, -1):
                check_item = sort_jpgSectors_tmp[jj]
                if check_item.start <= main_item.start <= check_item.end:
                    if check_item.start <= main_item.end <= check_item.end:
                        main_item.root = check_item.no
                        break
        jpgSectors.append(main_item)
    #
    #
    return jpgSectors
예제 #15
0
 def showHex(self):
     self.showHeader()
     print()
     s2hex(dataBytes=self.s8_all_data,
           dataName=Kind.findType(self.s0_app_marker).shortname)