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

feat: add exif based image rotation #37

Merged
merged 11 commits into from
Mar 19, 2023
Merged

feat: add exif based image rotation #37

merged 11 commits into from
Mar 19, 2023

Conversation

mryel00
Copy link
Owner

@mryel00 mryel00 commented Feb 21, 2023

This adds a basic exif based image rotation to solve #33.
Sending the exif header with the desired rotation before the frame will rotate the frame in all exif supporting browsers.
This adds the new cli parameter --orientation_exif and requires an integer based on the rotation desired.

In it's current form it always attaches the header, if the parameter is set. So there could be a case were the header is already there from the camera.

Signed-off-by: Patrick Gehrsitz 58853838+mryel00@users.noreply.github.com

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
@mryel00 mryel00 added the enhancement New feature or request label Feb 21, 2023
@mryel00 mryel00 linked an issue Feb 21, 2023 that may be closed by this pull request
Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
@roamingthings
Copy link
Collaborator

I've decoded the EXIF header generated by your tool manually and uploaded in a separate branch
Next I will try to remove everything exception the orientation.

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
@roamingthings
Copy link
Collaborator

@mryel00 can I update the PR with my branch? I would also like to move the header generation to a separate file for better testing.

@mryel00
Copy link
Owner Author

mryel00 commented Mar 11, 2023

@roamingthings do whatever you want 😄

@Caouette1988
Copy link

For your info: I'm using this branch right now for 1 week with no problems.

Signed-off-by: Alexander Sparkowsky <info@roamingthings.de>
Signed-off-by: Alexander Sparkowsky <info@roamingthings.de>
Signed-off-by: Alexander Sparkowsky <info@roamingthings.de>
@roamingthings
Copy link
Collaborator

@Caouette1988 I updated this branch and would appreciate if you give it a try

@roamingthings
Copy link
Collaborator

@mryel00 I've update the implementation. I'm not happy with the test setup I had to do. I will give it a closer look. However, the implementation of the feature should be fine.

spyglass/exif.py Outdated Show resolved Hide resolved
@Caouette1988
Copy link

Caouette1988 commented Mar 12, 2023

I just try to install it and it return some error.

  1. I'm only able to make it work by sending this command : ./run.py -b 0.0.0.0 -p 8080 -r 1536x864 -f 5 -st '/?action=stream' -sn '/?action=snapshot' -af continuous -l 0.0 -s normal -or r90

  2. Is there an error in spyglass.conf? It is still calling for ORIENTATION_EXIF="1" but it seem to want r90 instead of 1. I try it with success, but I don't know if it is because I installed the Start Developing command in the readme.

  3. spyglass.conf will need to be udated with these value in comment value :
    ' h - Horizontal (normal)\n'
    ' mh - Mirror horizontal\n'
    ' r180 - Rotate 180\n'
    ' mv - Mirror vertical\n'
    ' mhr270 - Mirror horizontal and rotate 270 CW\n'
    ' r90 - Rotate 90 CW\n'
    ' mhr90 - Mirror horizontal and rotate 90 CW\n'
    ' r270 - Rotate 270 CW'

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
@mryel00
Copy link
Owner Author

mryel00 commented Mar 12, 2023

@Caouette1988 thank you for spotting that error. It should be fixed now

Signed-off-by: Alexander Sparkowsky <info@roamingthings.de>
@Caouette1988
Copy link

@Caouette1988 thank you for spotting that error. It should be fixed now

i install it yesterday, all work good. Obico too is working.

@roamingthings
Copy link
Collaborator

@mryel00 I think this is ready for release. What do you think?

@mryel00
Copy link
Owner Author

mryel00 commented Mar 15, 2023

@roamingthings I'm not sure if we need something like a fail check for the first image to check if there is already an EXIF header. I guess this might be just a simple check for the EXIF identifier in the first few bytes but I'm not completely sure about that and if we should really implement it as there shouldn't be one in nearly all scenarios.

@roamingthings
Copy link
Collaborator

@mryel00 This would mean that picamera2 starts to embed EXIF data. I don't think that this will be an issue.

@mryel00
Copy link
Owner Author

mryel00 commented Mar 15, 2023

@roamingthings Ok I thought I read something about that somewhere but I could be just wrong 😅
Then everything should be ready for release

@mryel00 mryel00 marked this pull request as ready for review March 15, 2023 13:04
@mryel00 mryel00 requested a review from KwadFan as a code owner March 15, 2023 13:04
@roamingthings
Copy link
Collaborator

Well I think we would have to check the first few bytes for being an EXIF header. Shouldn't be that hard.

Signed-off-by: mryel00 <58853838+mryel00@users.noreply.github.com>
@roamingthings roamingthings self-requested a review March 19, 2023 15:17
Copy link
Collaborator

@roamingthings roamingthings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go

@mryel00 mryel00 merged commit ab73061 into main Mar 19, 2023
@mryel00 mryel00 deleted the add_exif_rotation branch March 19, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Add option to rotate the image
3 participants