Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Processing input via POST /ob/images causes images to become rotated #1630

Closed
placer14 opened this issue Jun 11, 2019 · 5 comments · Fixed by #1643
Closed

Processing input via POST /ob/images causes images to become rotated #1630

placer14 opened this issue Jun 11, 2019 · 5 comments · Fixed by #1643
Assignees
Labels

Comments

@placer14
Copy link
Member

Report from @drwasho indicates that the POST /ob/images endpoint either persists the rotated image or persists the original image yet returns a rotated image. Whichever the case, the response should be consistent with the original image.

@placer14 placer14 added the bug label Jun 11, 2019
@placer14
Copy link
Member Author

Attempted the following request against a local node using my graphic of choice:
(echo -n '[{"filename": "filename.png","image": "'; base64 ~/Desktop/tmp/sanic-little-steps.jpg; echo '"}]') | curl -H "Content-Type: application/json" -d @- 0.0.0.0:4002/ob/images

Which provided the following response:

[
    {
        "filename": "filename.png",
        "hashes": {
            "large": "QmQsWqKvYAMtUoKWim8f1axPYaUpwkH8yFJosL5Y7rHjWs",
            "medium": "QmdWJaxYVr1xJ8YduBoXtEuVNU5HKHQF58A2rTtBodzW4T",
            "original": "QmQkizhW5JUhCGhSNgnEMn5ySRBYAiuC1Xzh7shK32xYQV",
            "small": "QmZoPMNeSk5QWKwzjRSL2z8nKxMBBknW6Z9TobP6ZvLaAi",
            "tiny": "QmWXpJwaN4ZsKH7DQPZeuBa5167vzP2KmDQWXCLSdQuLbT"
        }
    }
]

Which looks normal when returned by the gateway: https://gateway.ob1.io/ob/images/QmQkizhW5JUhCGhSNgnEMn5ySRBYAiuC1Xzh7shK32xYQV

All seems fine to me.

@placer14
Copy link
Member Author

I was provided with an example case (which involves a JPG) that causes this issue described above. Steps to reproduce.
Using pic

  1. Download file to local filesystem.
  2. Start latest master of ob-go.
  3. POST the base64-encoded representation of the file to the daemon using the following:
(echo -n '[{"filename": "pic.jpg","image": "'; base64 ./<pathto>/pic.jpg; echo '"}]')  | curl -H "Content-Type: application/json" -d @- 0.0.0.0:4002/ob/images
  1. Note the hash of the Original value in the response and load the image on the gateway: https://gateway.ob1.io/ob/images/<hashofcontent>
  2. Note that it is rotated from the input.

@placer14 placer14 reopened this Jun 12, 2019
@placer14 placer14 self-assigned this Jun 13, 2019
@placer14 placer14 changed the title POST /ob/images returning rotated base64 encoding Processing input via POST /ob/images causes images to become rotated Jun 14, 2019
@placer14
Copy link
Member Author

After examining the ingress of this data and that the encoding really doesn't change as it's processed through, I began looking at the inherent state of the file (because this problem does not occur on all files equally). After taking some additional pictures using an android devices in various orientations, it appears that the EXIF data impacts how these files are interpreted in most GUIs despite the underlying data being different to what's presented. So while the data always "appears" to be right-side up in various utilities, these values are being stripped when processed through the daemon and forced into their natural orientation after processing. ...ultimately, this is the result of golang not considering the EXIF data and expecting this consideration to be handled manually before processing. After understanding the problem, the existing issues were much easier to find around this. (See: golang/go#4341)

Investigating how this can be properly handled in the face of the stdlib's disregard for that metadata.

@jjeffryes
Copy link
Collaborator

@placer14 sorry, I should have jumped in here earlier. We had this same issue in the desktop client long, long ago.

This is what we do:

  1. detect the orientation from the file when it is uploaded.
  2. use that to transform the image data to have the correct orientation.
  3. send the transformed image data to the server without any EXIF data.

If the Haven client did the same thing it should work fine. The code is in the onChangePhotoUploadInput method of the views.modals.editListing.EditListings.js file in the desktop repo.

@placer14
Copy link
Member Author

Too little, too late. Nevertheless, after this fix you should be able to simplify the desktop client. 🍻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants