Skip to content

Commit

Permalink
Allow merging of IFDs with different offset types. (#69)
Browse files Browse the repository at this point in the history
* Allow merging of IFDs with different offset types.

* add test

Co-authored-by: Tamas Nagy <[email protected]>
  • Loading branch information
dcjones and tlnagy authored Nov 5, 2021
1 parent a1f00c1 commit 61d16ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TiffImages"
uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69"
authors = ["Tamas Nagy <[email protected]>"]
version = "0.5.1"
version = "0.5.2"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down
4 changes: 2 additions & 2 deletions src/ifds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Base.delete!(ifd::IFD, key::TiffTag) = delete!(ifd, UInt16(key))
Base.delete!(ifd::IFD, key::UInt16) = delete!(ifd.tags, key)

Base.similar(::IFD{O}) where {O <: Unsigned} = IFD(O)
Base.merge(ifd::IFD{O}, other::IFD{O}) where {O <: Unsigned} = IFD(O, DefaultDict(Vector{Int}, merge(ifd.tags, other.tags)))
Base.merge(ifd::IFD{O}, other::IFD) where {O <: Unsigned} = IFD(O, DefaultDict(Vector{Int}, merge(ifd.tags, other.tags)))

Base.setindex!(ifd::IFD, value::Tag, key::UInt16) = setindex!(ifd.tags, [value], key)
Base.setindex!(ifd::IFD, value::Tag, key::TiffTag) = setindex!(ifd, value, UInt16(key))
Expand Down Expand Up @@ -248,4 +248,4 @@ function Base.write(tf::TiffFile{O}, ifd::IFD{O}) where {O <: Unsigned}
seek(tf, ifd_end_pos)

return ifd_end_pos
end
end
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,10 @@ end
@testset "Interpreting IFD layouts" begin
include("layouts.jl")
end

@testset "Issue #69" begin
rawarray = Gray.(zeros(10, 10, 2))
ifds = [TiffImages.IFD(UInt64), TiffImages.IFD(UInt64)]
# test that the constructor can handle small images using 64bit offsets
@test size(TiffImages.DenseTaggedImage(rawarray, ifds)) == size(rawarray)
end

2 comments on commit 61d16ec

@tlnagy
Copy link
Owner

@tlnagy tlnagy commented on 61d16ec Nov 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48271

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" 61d16ec308f82cfa181f9e84b1c03d9cf7f2a25c
git push origin v0.5.2

Please sign in to comment.