Skip to content

Commit

Permalink
Map jxl effort from 1..10 instead of 0..9 by #1274
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Aug 13, 2024
1 parent 5767e03 commit ee20853
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ internal abstract class SimpleCompressor {
},
compressionOption = JxlCompressionOption.LOSSY,
quality = jxlQuality.qualityValue,
effort = JxlEffort.entries.first { it.ordinal == jxlQuality.effort },
effort = JxlEffort.entries.first { it.ordinal == jxlQuality.effort - 1 },
decodingSpeed = JxlDecodingSpeed.entries.first { it.ordinal == jxlQuality.speed }
)
}
Expand All @@ -462,7 +462,7 @@ internal abstract class SimpleCompressor {
},
compressionOption = JxlCompressionOption.LOSSLESS,
quality = 100,
effort = JxlEffort.entries.first { it.ordinal == jxlQuality.effort },
effort = JxlEffort.entries.first { it.ordinal == jxlQuality.effort - 1 },
decodingSpeed = JxlDecodingSpeed.entries.first { it.ordinal == jxlQuality.speed }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ sealed class ImageFormat(
data object Lossless : Jxl(
title = "JXL Lossless",
compressionTypes = listOf(
CompressionType.Effort(0..9)
CompressionType.Effort(1..10)
)
)

data object Lossy : Jxl(
title = "JXL Lossy",
compressionTypes = listOf(
CompressionType.Quality(1..100),
CompressionType.Effort(0..9)
CompressionType.Effort(1..10)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sealed class Quality(
val value = this as? Jxl ?: return Jxl(qualityValue.coerceIn(1..100))
value.copy(
qualityValue = qualityValue.coerceIn(1..100),
effort = effort.coerceIn(0..9),
effort = effort.coerceIn(1..10),
speed = speed.coerceIn(0..4)
)
}
Expand Down Expand Up @@ -71,7 +71,7 @@ sealed class Quality(
data class Jxl(
@IntRange(from = 1, to = 100)
override val qualityValue: Int = 50,
@IntRange(from = 0, to = 9)
@IntRange(from = 1, to = 10)
val effort: Int = 5,
@IntRange(from = 0, to = 4)
val speed: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fun QualitySelector(
Text(
text = stringResource(
R.string.speed_sub,
0, 5
0, 4
),
fontSize = 12.sp,
textAlign = TextAlign.Center,
Expand Down

0 comments on commit ee20853

Please sign in to comment.