moustikitos / tyf Goto Github PK
View Code? Open in Web Editor NEWManipulate EXIF and IFD metadata.
Manipulate EXIF and IFD metadata.
Hi,
I just stumbled across your Tyf library. I need to write exif data to tiff files. But I can't figure out how to do it. Could you kindly give me a short example on how to write a UserComment to a tif file, so that the rest of the exif info is preserved?
Thanks...
Due to missing this file, setup.py failed to run.
I have an issue with the sub IFD InteropIFD : when I load a jpg and save it, it is missing or shown as corrupt in exiftool after (with this example, it's corrupted). I guess it's not the expected behaviour.
Before :
Interoperability Index : R98 - DCF basic file (sRGB)
Interoperability Version : 0100
after :
Warning : Bad InteropIFD directory
Steps :
jpg = Tyf.open('testori.jpg')
#Print some tags
for i in jpg.exif.tags():
print(i)
# eventually, (re)write 3-4 tags
jpg.save('testinterop.jpg')
The source file might be corrupted, but it should be original from the smartphone.
Files :
testori
testinterop
Python 3.5.2 64bit Win
Hello,
at first thanks for this library!!!
But i have little problem with some images. I wrote a script to add EXIF-Tags with GPS to Images which don't have any. This works ok as far i can see
part of script:
img = Image.open(os.path.join('pictures', filename))
exf = img._getexif()
exf[0]['GPSLatitude'] = lpi[2]
exf[0]['GPSLongitude'] = lpi[1]
exf[0]['GPSAltitude'] = 0.00
exf[1]['GPSLatitude'] = lpi[2]
exf[1]['GPSLongitude'] = lpi[1]
exf[1]['GPSAltitude'] = 0.00
img.save(os.path.join('tagged', 'tagged_' + filename), ifd=exf)
but jpg.exif.dump_location
doesnt create images of location. For any photo taken with my Iphone which adds GPS-Tags automatically it works.
What did i miss??
Thanks
Peter
Salut,
Ce problème n'apparait que sur une machine linux, le même fichier se lit correctement sur windows.
Ci-dessous le message d'erreur:
File "/usr/local/lib/python3.4/dist-packages/Tyf/__init__.py", line 58, in _read_IFD
typ = TYPES[typ][0]
KeyError: 0
Dispo si besoin d'infos complémentaires
Merci
Salut,
J'ai une erreur avec un geotiff :
/Tyf/gkd.py", line 105, in __init__
ValueError: "GeogGeodeticDatumGeoKey" value must be one of [6016, ... 6001], get 6171 instead
D'après la doc les valeurs entre 6000 et 6199 sont valides, le dictionnaire qu'ils présentent n'est donc pas exhaustif.
Possible de lever cette restriction ?
How do I modify XMP-related metadata?
'Xmp.MicrosoftPhoto.LensModel': 'test',
'Xmp.MicrosoftPhoto.CameraSerialNumber': 'CameraSerialNumber',
'Xmp.MicrosoftPhoto.DateAcquired': '20200606',
'Xmp.MicrosoftPhoto.FlashManufacturer': 'FlashManufacturer',
'Xmp.MicrosoftPhoto.FlashModel': 'FlashModel', # 闪光灯型号
'Xmp.MicrosoftPhoto.LensManufacturer': 'LensManufacturer'
Simple operation of (re)saving TIFF image file
i1 = Tyf.open( '/Users/xatx/Desktop/TEST.tiff' )
i1.save( '/Users/xatx/Desktop/TESTTyf.tiff' )
produces a corrupted file.
Hi there,
I am guessing this is a recurrence of previous issues.
This is a simple code:
import numpy as np
import Tyf
import tifffile as tiff
filename="Test.tif"
outputname="output.tif"
img = tiff.imread(filename)
exif_info = Tyf.open(filename)
tiff.imsave(outputname, img)
exif_info.save(outputname)
And I got following error:
Traceback (most recent call last):
File "J:/notebook/simple_test_exif.py", line 12, in
exif_info.save(outputname)
File "C:\Users\sean_\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 352, in save
next_ifd = to_buffer(i, fileobj, next_ifd, byteorder)
File "C:\Users\sean_\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 252, in to_buffer
next_ifd_offset = dump(obj, fileobj, offset, byteorder)
File "C:\Users\sean_\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 250, in dump
dump(getattr(i, "%s"%tag), f, i.get(tag).value[0], b)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 251, in dump
return write_IFD(i,f,o,b)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 162, in write_IFD
pack(byteorder+fmt, fileobj, value)
File "C:\Users\sean\AppData\Local\Programs\Python\Python37\lib\site-packages\Tyf_init_.py", line 14, in
pack = lambda fmt, fileobj, value: fileobj.write(struct.pack(fmt, *value))
struct.error: ubyte format requires 0 <= number <= 255
I've also attached the zipped TIF file for your reference.
Could you please take a look?
Thanks,
Sean
I may have missed the explanation about this, but I wanted to understand the format used in tags.py
and I had to find what is the second field, then try to see where those values are used. I figured out it's Type after following code.
Maybe a comment could be added to explain the format ?
Also I think the type specification system used, ie. list of integers, is hard to follow and should be written as enum if possible ?
Just my feedback from trying to understand how it works, but it might makes other/future maintainers life easier.
I'm testing a script to read and write a 16bit RGB-colored tiff file and find some error on data type. My test script is very simple like:
tif = Tyf.open(file_name)
tif.save(new_file_name)
and result in an error:
struct.error: ubyte format requires 0 <= number <= 255
After digging into the source file I find that data type of some tags might be wrong. For example in tags.py line 200, the ISOSpeedRatings
tag type is set as 1, while it is of type 3 when read from a tiff file (use function _read_IFD
in __init__.py
). Several data type mismatches has been found, including ExposureProgram
, MeteringMode
, Flash
, ColorSpace
, FocalPlaneResolutionUnit
, CustomRendered
, ExposureMode
, WhiteBalance
, SceneCaptureType
.
I'm not sure whether it is a problem of a special file format or of the OS platform, or anything else. Does anyone has met similar problems?
Hi,
Windows 10, python 3.5, blender 2.77, Pillow
throw an "I/O operation on closed file" exception on exif = Tyf.open(filepath)
when filepath is a jpg.
Seem to be a magic number issue
Ran into current pip: https://pypi.org/project/Tyf/ @ 1.3.2
Ran into bugger:
WARNING: Traceback (most recent call last):
File "<string>", line 29, in __plpython_procedure_find_exif_19256322
File "/usr/local/lib/python3.5/dist-packages/Tyf/ifd.py", line 75, in decode
return self._decoder(self.value)
File "/usr/local/lib/python3.5/dist-packages/Tyf/decoders.py", line 54, in <lambda>
_0x132 = _0x9003 = _0x9004 = lambda value: datetime.datetime.strptime(_2(value).decode(), "%Y:%m:%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'decode'
Reviewed current code and this was supposed to be fixed. Current pip is old code? Not sure.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.