Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of jpeg files not supported by standard java ImageIO (#384) #404

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dataset/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ project.setDescription("A KotlinDL library provides Dataset API and DSL to build

dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21'
implementation 'com.twelvemonkeys.imageio:imageio-jpeg:3.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions examples/src/test/kotlin/examples/io/IOTestSuite.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package examples.io

import examples.transferlearning.getFileFromResource
import org.jetbrains.kotlinx.dl.dataset.image.ImageConverter
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import javax.imageio.ImageIO
import javax.imageio.ImageReader


class IOTestSuite {
private val unsupportedJpegsFolder = getFileFromResource("jpeg_unsupported")

@Test
fun testJvmUnsupportedJpegLoading() {
val imageFiles = unsupportedJpegsFolder.walk().filter { it.isFile }

for (imageFile in imageFiles) {
assertDoesNotThrow("Failed to load image file $imageFile") {
imageFile.inputStream().use { inputStream -> ImageConverter.toBufferedImage(inputStream) }
}
}
}

@Test
fun testImageioJpegPluginIsUsed() {
val readers: Iterator<ImageReader> = ImageIO.getImageReadersByFormatName("JPEG")
val defaultReader = readers.next()
assert("com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader" in defaultReader.toString()) { "Default jpeg reader should be com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader" }
}
}