Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tiff metadata
#1
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
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question image manipulation (cropping and MetaData) SpongeB0B 4 1,100 Jul-03-2023, 06:35 PM
Last Post: SpongeB0B
  AttributeError: 'function' object has no attribute 'metadata 3lnyn0 5 4,522 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  OCR-Python from Multi TIFF to HOCR getting only Data from 1st Page of multiple TIFF JOE 0 2,120 Feb-18-2022, 03:18 PM
Last Post: JOE
  how to extract tiff images from the subfolder into. hocr format in another similar su JOE 0 1,131 Feb-16-2022, 06:28 PM
Last Post: JOE
  Compressed multi page tiff wvanoeveren 2 2,613 Dec-28-2021, 11:40 AM
Last Post: Gribouillis
  How to open/load image .tiff files > 2 GB ? hobbyist 1 2,385 Aug-19-2021, 12:50 AM
Last Post: Larz60+
  Unable to capture all images of a multipage TIFF file in a merge bendersbender 0 2,178 Nov-19-2020, 03:09 PM
Last Post: bendersbender
  Adding Language metadata to a PDF programmatically bhargavi22 0 1,911 Aug-17-2020, 12:53 PM
Last Post: bhargavi22
  METADATA Errors millpond 0 1,878 Jul-21-2020, 08:22 AM
Last Post: millpond
  Converting PNG to TIFF (pillow?) gw1500se 4 5,455 Mar-25-2020, 06:29 PM
Last Post: gw1500se

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020