[libcamera-devel,v4,2/8] android: jpeg: exif: Fix setOrientation EXIF values
diff mbox series

Message ID 20210125071444.26252-3-paul.elder@ideasonboard.com
State Superseded
Delegated to: Paul Elder
Headers show
Series
  • Fill in android result metadata and EXIF tags
Related show

Commit Message

Paul Elder Jan. 25, 2021, 7:14 a.m. UTC
The input to setOrientation is angle clockwise from the sensor
orientation, while the EXIF output values were swapped for 90
and 270 degrees.

From the EXIF spec:

6 = The 0th row is the visual right-hand side of the image, and the
    0th column is the visual top.
8 = The 0th row is the visual left-hand side of the image, and the
    0th column is the visual bottom.

6 should be 90 degrees clockwise, while 8 should 270 degrees clockwise.
Fix this.

As Android defines the rotation as the clockwise angle by which the
image needs to be rotated to appear in the correct orientation on the
device screen, the previous values would be correct if the input angle
was from the camera orientation. Since the correct input should be the
requested JPEG orientation, these new values are the correct ones.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
No change in v3

Changes in v2
- expand commit message
---
 src/android/jpeg/exif.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi Jan. 25, 2021, 11:03 a.m. UTC | #1
Hi Paul,

On Mon, Jan 25, 2021 at 04:14:38PM +0900, Paul Elder wrote:
> The input to setOrientation is angle clockwise from the sensor
> orientation, while the EXIF output values were swapped for 90
> and 270 degrees.
>
> From the EXIF spec:
>
> 6 = The 0th row is the visual right-hand side of the image, and the
>     0th column is the visual top.
> 8 = The 0th row is the visual left-hand side of the image, and the
>     0th column is the visual bottom.
>
> 6 should be 90 degrees clockwise, while 8 should 270 degrees clockwise.
> Fix this.
>
> As Android defines the rotation as the clockwise angle by which the
> image needs to be rotated to appear in the correct orientation on the
> device screen, the previous values would be correct if the input angle
> was from the camera orientation. Since the correct input should be the
> requested JPEG orientation, these new values are the correct ones.
>

Thanks for the much more clear commit message.

If I got this right, this has nothing to do with the camera
rotation, but only depends on the ANDROID_JPEG_ORIENTATION control
value.

With this confirmed:
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> ---
> No change in v3
>
> Changes in v2
> - expand commit message
> ---
>  src/android/jpeg/exif.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
> index 89343323..204a237a 100644
> --- a/src/android/jpeg/exif.cpp
> +++ b/src/android/jpeg/exif.cpp
> @@ -306,13 +306,13 @@ void Exif::setOrientation(int orientation)
>  		value = 1;
>  		break;
>  	case 90:
> -		value = 8;
> +		value = 6;
>  		break;
>  	case 180:
>  		value = 3;
>  		break;
>  	case 270:
> -		value = 6;
> +		value = 8;
>  		break;
>  	}
>
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
index 89343323..204a237a 100644
--- a/src/android/jpeg/exif.cpp
+++ b/src/android/jpeg/exif.cpp
@@ -306,13 +306,13 @@  void Exif::setOrientation(int orientation)
 		value = 1;
 		break;
 	case 90:
-		value = 8;
+		value = 6;
 		break;
 	case 180:
 		value = 3;
 		break;
 	case 270:
-		value = 6;
+		value = 8;
 		break;
 	}