Demo entry 6782236

Функция извлечения УЗИ изображений

   

Submitted by anonymous on Jan 11, 2019 at 06:25
Language: Python 3. Code size: 843 Bytes.

def load_pictures(_path_input, _path_save):
    data=bytearray(open(_path_input, 'rb').read())
    start=0
    finish=0
    found=False
    current=0
    FF=255
    D8=216
    D9=217
    img_count=0
    for i in range(len(data)-1):
        if ((data[i] == FF) and (data[i + 1] == D8)):
            start=i
            found=True
        if ((data[i] == FF) and (data[i + 1] == D9) and found):
            finish=i
            picture_size = finish - start + 1
            found = False
            picture=bytearray(0)

            for j in range(start, finish+2):
                picture.append(data[j])
                current+=1
            img_count+=1
            current=0
            newFile = open(_path_save+'/'+(str(img_count)+".jpg"), 'wb')
            newFile.write(picture)
            newFile.close()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).