Commit af08f522 authored by Him188's avatar Him188

Fix toExternalImage

parent 9f0169c6
...@@ -6,7 +6,6 @@ import io.ktor.util.asStream ...@@ -6,7 +6,6 @@ import io.ktor.util.asStream
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.io.core.Input import kotlinx.io.core.Input
import kotlinx.io.core.IoBuffer
import kotlinx.io.core.buildPacket import kotlinx.io.core.buildPacket
import kotlinx.io.core.copyTo import kotlinx.io.core.copyTo
import kotlinx.io.errors.IOException import kotlinx.io.errors.IOException
...@@ -61,13 +60,14 @@ fun File.toExternalImage(): ExternalImage { ...@@ -61,13 +60,14 @@ fun File.toExternalImage(): ExternalImage {
?: error("Unable to read file(path=${this.path}), no ImageReader found") ?: error("Unable to read file(path=${this.path}), no ImageReader found")
image.input = input image.input = input
val inputStream = this.inputStream()
return ExternalImage( return ExternalImage(
width = image.getWidth(0), width = image.getWidth(0),
height = image.getHeight(0), height = image.getHeight(0),
md5 = this.inputStream().use { it.md5() }, md5 = this.inputStream().md5(), // dont change
imageFormat = image.formatName, imageFormat = image.formatName,
input = this.inputStream().asInput(IoBuffer.Pool), input = inputStream.asInput(),
inputSize = this.length(), inputSize = inputStream.available().toLong(),
filename = this.name filename = this.name
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment