Skip to content

Commit

Permalink
Dependency updates + JAVA NIO API (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanOltmann authored Apr 22, 2024
1 parent 42edf90 commit d3dac70
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ of Ashampoo Photo Organizer, which, in turn, is driven by user community feedbac
## Installation

```
implementation("com.ashampoo:kim:0.17.6")
implementation("com.ashampoo:kim:0.17.7")
```

For the targets `wasmJs` & `js` you also need to specify this:
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ repositories {

val productName = "Ashampoo Kim"

val ktorVersion: String = "2.3.8"
val ktorVersion: String = "2.3.10"
val xmpCoreVersion: String = "1.2.2"
val dateTimeVersion: String = "0.5.0"
val testRessourcesVersion: String = "0.4.0"
val ioCoreVersion: String = "0.3.2"
val kotlinxIoVersion: String = "0.3.3"

description = productName
group = "com.ashampoo"
Expand Down Expand Up @@ -203,7 +203,7 @@ kotlin {
/* Kotlin Test */
implementation(kotlin("test"))

implementation("org.jetbrains.kotlinx:kotlinx-io-core:$ioCoreVersion")
implementation("org.jetbrains.kotlinx:kotlinx-io-core:$kotlinxIoVersion")
}
}

Expand Down Expand Up @@ -256,7 +256,7 @@ kotlin {
*
* Not available in commonMain due to missing JS browser support.
*/
api("org.jetbrains.kotlinx:kotlinx-io-core:$ioCoreVersion")
api("org.jetbrains.kotlinx:kotlinx-io-core:$kotlinxIoVersion")
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/kim-java-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
}

dependencies {
implementation 'com.ashampoo:kim:0.17.3'
implementation 'com.ashampoo:kim:0.17.7'
}

// Needed to make it work for the Gradle java plugin
Expand Down
2 changes: 1 addition & 1 deletion examples/kim-kotlin-jvm-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ repositories {
}

dependencies {
implementation("com.ashampoo:kim:0.17.3")
implementation("com.ashampoo:kim:0.17.7")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ashampoo.kim
package com.ashampoo.kim.android

import com.ashampoo.kim.Kim
import com.ashampoo.kim.common.ImageReadException
import com.ashampoo.kim.format.ImageMetadata
import com.ashampoo.kim.input.AndroidInputStreamByteReader
import java.io.File
import java.io.InputStream

/**
* Extra object to have a nicer API for Java projects
*/
object KimAndroid {

@JvmStatic
@Throws(ImageReadException::class)
fun readMetadata(inputStream: InputStream, length: Long): ImageMetadata? =
Kim.readMetadata(AndroidInputStreamByteReader(inputStream, length))

@JvmStatic
@Throws(ImageReadException::class)
fun readMetadata(path: String): ImageMetadata? =
readMetadata(File(path))

@JvmStatic
@Throws(ImageReadException::class)
fun readMetadata(file: File): ImageMetadata? {

check(file.exists()) { "File does not exist: $file" }

return readMetadata(file.inputStream().buffered(), file.length())
}
}

@Throws(ImageReadException::class)
fun Kim.readMetadata(inputStream: InputStream, length: Long): ImageMetadata? =
Kim.readMetadata(AndroidInputStreamByteReader(inputStream, length))
KimAndroid.readMetadata(inputStream, length)

@Throws(ImageReadException::class)
fun Kim.readMetadata(path: String): ImageMetadata? =
Kim.readMetadata(File(path))
KimAndroid.readMetadata(path)

@Throws(ImageReadException::class)
fun Kim.readMetadata(file: File): ImageMetadata? {

check(file.exists()) { "File does not exist: $file" }

return Kim.readMetadata(file.inputStream(), file.length())
}
fun Kim.readMetadata(file: File): ImageMetadata? =
KimAndroid.readMetadata(file)
20 changes: 19 additions & 1 deletion src/jvmMain/kotlin/com/ashampoo/kim/jvm/KimJvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.ashampoo.kim.format.ImageMetadata
import com.ashampoo.kim.input.JvmInputStreamByteReader
import java.io.File
import java.io.InputStream
import java.nio.file.Files
import java.nio.file.StandardOpenOption

/**
* Extra object to have a nicer API for Java projects
Expand All @@ -43,7 +45,19 @@ object KimJvm {

check(file.exists()) { "File does not exist: $file" }

return readMetadata(file.inputStream(), file.length())
return readMetadata(file.inputStream().buffered(), file.length())
}

@JvmStatic
@Throws(ImageReadException::class)
fun readMetadata(path: java.nio.file.Path): ImageMetadata? {

check(Files.exists(path)) { "File does not exist: $path" }

return readMetadata(
inputStream = Files.newInputStream(path, StandardOpenOption.READ).buffered(),
length = Files.size(path)
)
}
}

Expand All @@ -58,3 +72,7 @@ fun Kim.readMetadata(path: String): ImageMetadata? =
@Throws(ImageReadException::class)
fun Kim.readMetadata(file: File): ImageMetadata? =
KimJvm.readMetadata(file)

@Throws(ImageReadException::class)
fun Kim.readMetadata(path: java.nio.file.Path): ImageMetadata? =
KimJvm.readMetadata(path)

0 comments on commit d3dac70

Please sign in to comment.