Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with saving #14

Closed
seanliu-oss opened this issue Nov 17, 2020 · 5 comments
Closed

Issue with saving #14

seanliu-oss opened this issue Nov 17, 2020 · 5 comments

Comments

@seanliu-oss
Copy link

seanliu-oss commented Nov 17, 2020

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

test.zip

@Moustikitos
Copy link
Owner

Hi,

I'l having a look to this issue right now.
Was workin on two other projects giving me hard time.

Thank for the report.

@Moustikitos
Copy link
Owner

Hi,

I just did a test with your Tif

>>> t = Tyf.open("test/issue #14.tif") 
<IFD tag RowsPerStrip:None>: EncodingException('4294967295 not in range [0:256[')
>>> t.save("output.tif")
<IFD tag StripOffsets:27706>: EncodingException('27593 not in range [0:256[')

output.tif is a valid tif file. Did you get last version of Tyf ? (ie Github)
Looks like StripOffset type is not correct, should not be Byte type... I'll have a look @ it.

@Moustikitos
Copy link
Owner

Ok,

I had a better look to my code : StripOffset is either a Byte or a Long. Code automatically switches to correct type.
Tell me if your issue still there with a clone of git repo.

Thanks.

@seanliu-oss
Copy link
Author

Sorry haven't got a chance testing this. Will test and report back.

@seanliu-oss
Copy link
Author

Hi,
Installed the latest version (1.4.2) by cloning the git repo.
The saving seems to work properly in spite of the exceptions. So I'll consider this issue closed, but it would be nicer if the messages get cleaned up.
: EncodingException('4294967295 not in range [0:256[')
: EncodingException('318 not in range [0:256[')

Thanks,
Sean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants