Skip to content

Commit

Permalink
Bugfix for reading compressed images. (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnarFarneback authored Jun 23, 2021
1 parent 5bf7d9c commit 46e5908
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ifds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function Base.read!(target::AbstractArray{T, N}, tf::TiffFile, ifd::IFD) where {
catch
end

if !iscontiguous(ifd)
if !iscontiguous(ifd) || compression != COMPRESSION_NONE
rowsperstrip = rows
(ROWSPERSTRIP in ifd) && (rowsperstrip = ifd[ROWSPERSTRIP].data)
nstrips = ceil(Int, rows / rowsperstrip)
Expand All @@ -136,8 +136,8 @@ function Base.read!(target::AbstractArray{T, N}, tf::TiffFile, ifd::IFD) where {
if compression != COMPRESSION_NONE
# strip_nbytes is the number of bytes pre-inflation so we need to
# calculate the expected size once decompressed and update the values
strip_nbytes = fill(rowsperstrip*cols, length(strip_nbytes)::Int)
strip_nbytes[end] = (rows - (rowsperstrip * (nstrips-1))) * cols
strip_nbytes = fill(rowsperstrip*cols*sizeof(T), length(strip_nbytes)::Int)
strip_nbytes[end] = (rows - (rowsperstrip * (nstrips-1))) * cols * sizeof(T)
end

startbyte = 1
Expand Down

0 comments on commit 46e5908

Please sign in to comment.