Skip to content

Commit

Permalink
ImageModelTest requires optional field to be fully populated.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytw1 committed Oct 12, 2024
1 parent 0a4c37b commit 53186bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@ object MappingTest {
size = Some(1234L),
mimeType = Some(Jpeg),
dimensions = Some(Dimensions(500, 1000)),
secureUrl = Some(new URL("http://host/thumb.jpg"))
secureUrl = Some(new URL("http://host/thumb.jpg")),
orientationMetadata = Some(OrientationMetadata(exifOrientation = Some(6))),
orientedDimensions = Some(Dimensions(2000, 1000))
)),
optimisedPng = Some(Asset(
file = new URI("file://filename.png"),
size = Some(1245L),
mimeType = Some(Png),
dimensions = Some(Dimensions(1000, 2000)),
secureUrl = Some(new URL("http://host/filename.jpg"))
secureUrl = Some(new URL("http://host/filename.jpg")),
orientationMetadata = Some(OrientationMetadata(exifOrientation = Some(6))),
orientedDimensions = Some(Dimensions(2000, 1000))
)),
fileMetadata = FileMetadata(
iptc = Map("iptc1" -> "value1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class ImageOperations(playPath: String) extends GridLogging {
yield outputFile
}

private def orient(op: IMOperation, orientation: Option[OrientationMetadata]): IMOperation = {
logger.info("Correcting for orientation: " + orientation)
orientation.map(_.orientationCorrection()) match {
private def orient(op: IMOperation, orientationMetadata: Option[OrientationMetadata]): IMOperation = {
logger.info("Correcting for orientation: " + orientationMetadata)
orientationMetadata.map(_.orientationCorrection()) match {
case Some(angle) => rotate(op)(angle)
case _ => op
}
Expand Down Expand Up @@ -180,12 +180,12 @@ class ImageOperations(playPath: String) extends GridLogging {
outputFile: File,
iccColourSpace: Option[String],
colourModel: Option[String],
orientation: Option[OrientationMetadata]
orientationMetadata: Option[OrientationMetadata]
)(implicit logMarker: LogMarker): Future[(File, MimeType)] = {
val stopwatch = Stopwatch.start

val cropSource = addImage(browserViewableImage.file)
val orientated = orient(cropSource, orientation)
val orientated = orient(cropSource, orientationMetadata)
val thumbnailed = thumbnail(orientated)(width)
val corrected = correctColour(thumbnailed)(iccColourSpace, colourModel, browserViewableImage.isTransformedFromSource)
val converted = applyOutputProfile(corrected, optimised = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ case class OrientationMetadata(exifOrientation: Option[Int]) {
}

private def flipsDimensions(): Boolean = exifOrientation.exists(OrientationMetadata.exifOrientationsWhichFlipWidthAndHeight.contains)

}

object OrientationMetadata {
Expand Down

0 comments on commit 53186bf

Please sign in to comment.