Moustikitos / tyf

Manipulate EXIF and IFD metadata.
19 stars 8 forks source link

wrong data type? #12

Closed LoveDaisy closed 3 years ago

LoveDaisy commented 7 years ago

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?

Moustikitos commented 7 years ago

Hi,

It is a first one. What is the provenance of thetiff File (camera model, ...)

Thanks

LoveDaisy commented 7 years ago

My picture is taken originally by a Canon 6D Mark II camera, and use Adobe Camera Raw to decode the raw file and export as a 16bit RGB tiff file. All metadata are shown correct in Adobe Lightroom. I can email you the tiff file if necessary.

P.S. After I correct those mismatches in source file and run my script again, everything goes OK.

Moustikitos commented 7 years ago

thanks for the details. Will check thecode on the type tag attribution

Moustikitos commented 3 years ago

Fixed with last commit