-
Notifications
You must be signed in to change notification settings - Fork 14
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
Tiff is saved with uncompleted tag content #77
Comments
This is definitely a bug. My best guess is that somehow the length of the string is being computed incorrectly? |
So after digging into this a bit more, it looks like this is caused by the UTF-8 encoding of the OME-XML. julia> using TiffImages
julia> tf = TiffImages.TiffFile(UInt32);
julia> tag = TiffImages.Tag(TiffImages.IMAGEDESCRIPTION, "αβγ") # extended characters
Tag(IMAGEDESCRIPTION, "αβγ")
julia> write(tf, tag) # this should be false, because extended chars take up more space
true
julia> seekstart(tf.io);
julia> read(tf, TiffImages.Tag) # the last character is missing!
Tag(IMAGEDESCRIPTION, "αβ")
julia> sizeof(tag) # this would be correct if characters were ascii
4
julia> sizeof(tag.data) # what the actual length is
6 The TIFF standard was written prior to UTF-8 so it doesn't seem like there's a standardized way to handle this. But given that Julia uses UTF-8 basically everywhere, we should do our best to encode it properly. |
Using `ncodeunits` handles the variable byte lengths for UTF-8 strings properly.
This should be fixed by #78, could you please test the latest dev version and see if that fixed your problem? Also, if you are working on a writer for OME-TIFF files, it would be fantastic if you could submit a PR over at OMETIFF.jl! I've been meaning to do that forever, and would very happy to review it. EDIT: For at least three years 😅 tlnagy/OMETIFF.jl#30 |
Thanks, I'm working at adapting this code to generate omexml. Although this implementation is only subset of OMEXML, I think it may be very helpful to manage multi dimensions image. |
Hi, I try to write below omexml to
TiffImages.IMAGEDESCRIPTION
tag and save tiff, but saved tiff's IMAGEDESCRIPTION tag always lose final 2 chars! It is so weird... For example, if the original is...</OME>\n
, saved tiff will be...</OME
(julia take\n
as a char ). But the dump xml from OMETIFF.jl and simple strings don't show this issue. As the same time, exiftool write tag normally.The final goal is to save OMETIFF. To do that, I have to add two more chars in original xml:
...</OME>\n
=>...</OME>\n>\n
. It will be convenient and excited to write OMETIFF, so I'm looking for your idea.The text was updated successfully, but these errors were encountered: