Tiff metadata - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Tiff metadata (/thread-12106.html) |
Tiff metadata - sudecki - Aug-09-2018 Hi, I am new on the forum, I search a solution for my work. I process Tiff image of Olynpus miscroscope. And inside image, you can find some details of acquisitions but you can't read with anyEXIF reader. I try to do a code to read of original image and write on a proccesing image. I am sorry it is not beautiful code. But when I do this, i create a corrupt file. I try a lot Exif or Tiff libreary. But any can't read these elements. Can you help me? My code: nfc=path+nom ######Read metadata on the original file fd = open(nfc, encoding='utf-16-be') d= fd.read() x_start = d.find('analySIS') x_end = d.find('Solutions') x_str = d[:xmp_end+11] x_str2 = d[xmp_start-16:] fd.close() ######Write #read the image data fd = open(os.path.join(path2,nom), encoding='utf-16-be') d= fd.read() fd.close() #add metadata on image of the orinal image d=x_str+d[140:]+x_str2 fd = open(os.path.join(path2,nom), 'w+',encoding='utf-16-be') fd.write(d) fd.close()And the image file: (You can open with notepad, informations I want are at the begening and at the end.) Image TIFF I work on windows 7 with Python3.6 64bits, because I process image with an IA. Thanks RE: Tiff metadata - sudecki - Aug-10-2018 Hi, I have found ######Read metadata on the original file fd = open(nfc, 'rb') d= fd.read() xmp_start = re.search(b'analySIS',d) xmp_end = re.search(b'Solutions',d) xmp_str = d[:xmp_end.span()[0]+11] xmp_str2 = d[xmp_start.span()[0]-16:] fd.close() ######Write img2.save(os.path.join(path2,nom)) fd = open(os.path.join(path2,nom), 'rb') d= fd.read() fd.close() d=xmp_str+d[140:]+xmp_str2 fd = open(os.path.join(path2,nom), 'w+b') fd.write(d) fd.close() |