Skip to content

Commit

Permalink
Fixed cut-off bug in PngChunkText (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanOltmann authored Feb 5, 2024
1 parent 5d1b28e commit a3619e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ of Ashampoo Photos, which, in turn, is driven by user community feedback.
## Installation

```
implementation("com.ashampoo:kim:0.13.1")
implementation("com.ashampoo:kim:0.13.2")
```

## Sample usages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,19 @@ class PngChunkText(

init {

val index = bytes.indexOfNullTerminator()
val nullTerminatorIndex = bytes.indexOfNullTerminator()

if (index < 0)
if (nullTerminatorIndex < 0)
throw ImageReadException("PNG tEXt chunk keyword is not terminated.")

keyword = bytes.copyOfRange(
fromIndex = 0,
toIndex = index
toIndex = nullTerminatorIndex
).decodeLatin1BytesToString()

val textLength = bytes.size - (index + 1)

text = bytes.copyOfRange(
fromIndex = index + 1,
toIndex = textLength
fromIndex = nullTerminatorIndex + 1,
toIndex = bytes.size
).decodeLatin1BytesToString()
}

Expand Down

0 comments on commit a3619e0

Please sign in to comment.