diff --git a/README.md b/README.md index 9d8790f5..c957d691 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kim - Kotlin Image Metadata -[![Kotlin](https://img.shields.io/badge/kotlin-2.0.20-blue.svg?logo=kotlin)](httpw://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-2.0.21-blue.svg?logo=kotlin)](httpw://kotlinlang.org) ![JVM](https://img.shields.io/badge/-JVM-gray.svg?style=flat) ![Android](https://img.shields.io/badge/-Android-gray.svg?style=flat) ![iOS](https://img.shields.io/badge/-iOS-gray.svg?style=flat) @@ -39,7 +39,7 @@ of Ashampoo Photo Organizer, which, in turn, is driven by user community feedbac ## Installation ``` -implementation("com.ashampoo:kim:0.19") +implementation("com.ashampoo:kim:0.20") ``` For the targets `wasmJs` & `js` you also need to specify this: @@ -53,7 +53,7 @@ implementation(npm("pako", "2.1.0")) ### Read metadata `Kim.readMetadata()` takes `kotlin.ByteArray` on all platforms and depending on -the platform also `kotlinx.io.files.Path`, Ktor `ByteReadPacket` & `ByteReadChannel`, +the platform also `kotlinx.io.files.Path`, Ktor `Source` & `ByteReadChannel`, `java.io.File`, `java.io.InputStream`, `NSData` and `String` paths. ```kotlin diff --git a/build.gradle.kts b/build.gradle.kts index 00613fc9..32eed17e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,11 +24,10 @@ repositories { val productName: String = "Ashampoo Kim" -val ktorVersion: String = "2.3.12" -val xmpCoreVersion: String = "1.4.1" +val ktorVersion: String = "3.0.0" +val xmpCoreVersion: String = "1.4.2" val dateTimeVersion: String = "0.6.1" -val testRessourcesVersion: String = "0.4.0" -val kotlinxIoVersion: String = "0.5.3" +val kotlinxIoVersion: String = "0.5.4" description = productName group = "com.ashampoo" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 707e499a..5c40527d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/commonTest/resources/com/ashampoo/kim/testdata/xmp/acdsee_sample_mod.xmp b/src/commonTest/resources/com/ashampoo/kim/testdata/xmp/acdsee_sample_mod.xmp index 53714ab1..c10a5207 100644 --- a/src/commonTest/resources/com/ashampoo/kim/testdata/xmp/acdsee_sample_mod.xmp +++ b/src/commonTest/resources/com/ashampoo/kim/testdata/xmp/acdsee_sample_mod.xmp @@ -1,5 +1,5 @@ - + - + - + - + - + - + - + - + - + - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg index d0df475a..bb90c188 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg and b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg.txt b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg.txt index eb134485..0993f164 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_persons.jpg.txt @@ -135,7 +135,7 @@ Keywords (25) = 'people' ---- XMP ---- - + - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg index fbbd2518..2c82d1a4 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg and b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg.txt b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg.txt index a54283d8..b98da991 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_jpg/new_rating.jpg.txt @@ -135,7 +135,7 @@ Keywords (25) = 'people' ---- XMP ---- - + - + - + - + - + - + - + - + - + - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl index 4ae37b78..636a0593 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl and b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl.txt b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl.txt index b1642351..3e425bce 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_persons.jxl.txt @@ -61,7 +61,7 @@ Little-endian (Intel, II) ---- XMP ---- - + - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl index 90e20f7f..cfe51c25 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl and b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl.txt b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl.txt index 34da6b47..1b3163ec 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_jxl/new_rating.jxl.txt @@ -61,7 +61,7 @@ Little-endian (Intel, II) ---- XMP ---- - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png index ab8642fc..195d50c0 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png.txt index 48402f5a..294065df 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.no_metadata.png.txt @@ -10,7 +10,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png index 1bf27626..7a494f10 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png.txt index 1760e095..dfc287fa 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_keywords.png.txt @@ -130,7 +130,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png index 2be12c0b..9a1a69ac 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png.txt index 3d6698e8..1dca22a2 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.no_metadata.png.txt @@ -10,7 +10,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png index c8af609c..18c1db00 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png.txt index 702be082..97b94920 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_persons.png.txt @@ -130,7 +130,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png index e4f8cad3..2fb542f2 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png.txt index 7a8454bd..411ec81a 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_rating.no_metadata.png.txt @@ -10,7 +10,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png index caa36cee..f848e179 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png.txt index 6258bb89..412c618c 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/new_taken_date.no_metadata.png.txt @@ -20,7 +20,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png b/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png index 03617081..c3451c07 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png and b/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png.txt b/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png.txt index b8905eb4..155f4fef 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_png/rotated_right.no_metadata.png.txt @@ -19,7 +19,7 @@ Time Created (60) = '15:28:58-15:28' ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp index c4e3a1c8..ef4b96b9 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp.txt index 7a3f4edd..7b67c793 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_gps_coordinates.no_metadata.webp.txt @@ -18,7 +18,7 @@ Big-endian (Motorola, MM) ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp index 585ab8a2..527983f4 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp.txt index 381ee8fe..66068da1 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.no_metadata.webp.txt @@ -2,7 +2,7 @@ File format : WEBP Resolution : 5184 x 3456 ---- XMP ---- - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp index 33e11f29..260b998d 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp.txt index 7149ed57..f254b3cf 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_keywords.webp.txt @@ -62,7 +62,7 @@ Little-endian (Intel, II) ---- XMP ---- - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp index cb3c5fc8..9efc4c6b 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp.txt index 694572dd..f75c9408 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.no_metadata.webp.txt @@ -2,7 +2,7 @@ File format : WEBP Resolution : 5184 x 3456 ---- XMP ---- - + diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp index 6a704eeb..09108f5a 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp.txt index 90a6c151..1ae0cae0 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_persons.webp.txt @@ -62,7 +62,7 @@ Little-endian (Intel, II) ---- XMP ---- - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp index b4aa1656..f56465ee 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp.txt index a277e80b..805ebc47 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_rating.no_metadata.webp.txt @@ -2,7 +2,7 @@ File format : WEBP Resolution : 5184 x 3456 ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp index 4d76ecc4..a6debae7 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp.txt index 61f079e6..fd56ae00 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/new_taken_date.no_metadata.webp.txt @@ -12,7 +12,7 @@ Big-endian (Motorola, MM) ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp b/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp index 32aa8c44..d8b93096 100644 Binary files a/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp and b/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp differ diff --git a/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp.txt b/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp.txt index 15ab8554..84e9a14f 100644 --- a/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp.txt +++ b/src/commonTest/resources/com/ashampoo/kim/updates_webp/rotated_right.no_metadata.webp.txt @@ -11,7 +11,7 @@ Big-endian (Motorola, MM) ---- XMP ---- - + - + - + \ No newline at end of file diff --git a/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorByteReadChannelByteReader.kt b/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorByteReadChannelByteReader.kt index 0311c86c..4b03aec5 100644 --- a/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorByteReadChannelByteReader.kt +++ b/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorByteReadChannelByteReader.kt @@ -17,8 +17,9 @@ package com.ashampoo.kim.input import io.ktor.utils.io.ByteReadChannel import io.ktor.utils.io.cancel -import io.ktor.utils.io.core.readBytes +import io.ktor.utils.io.readRemaining import kotlinx.coroutines.runBlocking +import kotlinx.io.readByteArray /** * This class allows streaming data from a cloud service and read only the headers. @@ -41,7 +42,7 @@ public class KtorByteReadChannelByteReader( return null buffer = runBlocking { - channel.readRemaining(limit = bufferSize).readBytes() + channel.readRemaining(max = bufferSize).readByteArray() } bufferLimit = buffer.size bufferOffset = 0 @@ -64,7 +65,7 @@ public class KtorByteReadChannelByteReader( break buffer = runBlocking { - channel.readRemaining(limit = bufferSize).readBytes() + channel.readRemaining(max = bufferSize).readByteArray() } bufferLimit = buffer.size bufferOffset = 0 diff --git a/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorInputByteReader.kt b/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorInputByteReader.kt index eee2966d..63faa4d4 100644 --- a/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorInputByteReader.kt +++ b/src/ktorMain/kotlin/com/ashampoo/kim/input/KtorInputByteReader.kt @@ -15,8 +15,10 @@ */ package com.ashampoo.kim.input -import io.ktor.utils.io.core.ByteReadPacket -import io.ktor.utils.io.core.readBytes +import io.ktor.utils.io.core.endOfInput +import io.ktor.utils.io.core.remaining +import kotlinx.io.Source +import kotlinx.io.readByteArray /** * This class provides a convenient way to parse metadata directly from @@ -24,17 +26,17 @@ import io.ktor.utils.io.core.readBytes * of files hosted on a cloud service, which is a common use case. */ public class KtorInputByteReader( - private val byteReadPacket: ByteReadPacket + private val source: Source ) : ByteReader { - override val contentLength: Long = byteReadPacket.remaining + override val contentLength: Long = source.remaining override fun readByte(): Byte? = - if (byteReadPacket.endOfInput) null else byteReadPacket.readByte() + if (source.endOfInput) null else source.readByte() override fun readBytes(count: Int): ByteArray = - byteReadPacket.readBytes(minOf(count, byteReadPacket.remaining.toInt())) + source.readByteArray(minOf(count, source.remaining.toInt())) override fun close(): Unit = - byteReadPacket.close() + source.close() } diff --git a/src/ktorMain/kotlin/com/ashampoo/kim/ktor/KimKtor.kt b/src/ktorMain/kotlin/com/ashampoo/kim/ktor/KimKtor.kt index 5f25f2c2..0a2c816d 100644 --- a/src/ktorMain/kotlin/com/ashampoo/kim/ktor/KimKtor.kt +++ b/src/ktorMain/kotlin/com/ashampoo/kim/ktor/KimKtor.kt @@ -21,7 +21,7 @@ import com.ashampoo.kim.format.ImageMetadata import com.ashampoo.kim.input.KtorByteReadChannelByteReader import com.ashampoo.kim.input.KtorInputByteReader import io.ktor.utils.io.ByteReadChannel -import io.ktor.utils.io.core.ByteReadPacket +import kotlinx.io.Source import kotlin.jvm.JvmStatic /** @@ -31,8 +31,8 @@ public object KimKtor { @JvmStatic @Throws(ImageReadException::class) - public fun readMetadata(byteReadPacket: ByteReadPacket): ImageMetadata? = - Kim.readMetadata(KtorInputByteReader(byteReadPacket)) + public fun readMetadata(source: Source): ImageMetadata? = + Kim.readMetadata(KtorInputByteReader(source)) @JvmStatic @Throws(ImageReadException::class) @@ -41,8 +41,8 @@ public object KimKtor { } @Throws(ImageReadException::class) -public fun Kim.readMetadata(byteReadPacket: ByteReadPacket): ImageMetadata? = - KimKtor.readMetadata(byteReadPacket) +public fun Kim.readMetadata(source: Source): ImageMetadata? = + KimKtor.readMetadata(source) @Throws(ImageReadException::class) public fun Kim.readMetadata(byteReadChannel: ByteReadChannel, contentLength: Long): ImageMetadata? =