1

I have implemented a input file image capture in my web app to let an user take a picture and upload it. However, the image appears upside down when they have the tablet upside down. When using the camera app outside the app, it doesn't matter how you take the picture, its always upside up.

How can I force this in my web app?

Arko Elsenaar
  • 1,689
  • 3
  • 18
  • 33
  • When uploading the file you can try and test for metadata defining the `orientation` of the image and then rotate the image appropriately on the server when you're saving the uploaded file data. However to have a concise answer to this we'd need to know your server code (ex. `PHP`? `Perl`?) you're using to handle the upload. – Martin Sep 06 '16 at 14:07
  • Can you clarify your question please. – Martin Sep 06 '16 at 14:30
  • Possible duplicate of [How to deal with iOS taking upside down picture](https://stackoverflow.com/questions/24676333/how-to-deal-with-ios-taking-upside-down-picture) – la.urin Jul 09 '18 at 11:59

1 Answers1

0

You should be able to read the window orientation using javascript

function readDeviceOrientation() {

switch (window.orientation) {  
case 0:  

    // Portrait 
    break; 

case 180:  

    // Portrait (Upside-down)
    break; 

case -90:  

    // Landscape (Clockwise)
    break;  

case 90:  

    // Landscape  (Counterclockwise)
    break;
}

documentation

Joshua Duxbury
  • 4,892
  • 4
  • 32
  • 51
  • I *think* OP rather wants the image to rotate rather than the device – Martin Sep 06 '16 at 14:05
  • @Marin, excuse me if i'm not understanding.. The above let's you know the rotation of the "device"? Once you know the ration you can write additional scripts to rotate the video/photo? – Joshua Duxbury Sep 06 '16 at 14:21
  • I understood that the uploaded image was always the wrong way round (180deg rotation) compared to device, device rotation wasn't the issue but that image was saved on the server incorrectly rotated. Sorry if we're confusing each other! – Martin Sep 06 '16 at 14:29
  • @Martin just reread the OP's question and you're correct. The picture is always 180 deg regardless of rotation. My mistake sorry. – Joshua Duxbury Sep 06 '16 at 14:44