diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/MappingTest.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/MappingTest.scala index a160e0ebcc..1a2fbf9d97 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/MappingTest.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/MappingTest.scala @@ -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"), diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/imaging/ImageOperations.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/imaging/ImageOperations.scala index b7f574deef..2ded6ad873 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/imaging/ImageOperations.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/imaging/ImageOperations.scala @@ -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 } @@ -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) diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala index 62ecb5e357..6492d72191 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala @@ -86,6 +86,7 @@ case class OrientationMetadata(exifOrientation: Option[Int]) { } private def flipsDimensions(): Boolean = exifOrientation.exists(OrientationMetadata.exifOrientationsWhichFlipWidthAndHeight.contains) + } object OrientationMetadata {