Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 6 Safari Image Upload - Orientation Wrong
    primarykey
    data
    text
    <p>I've built a web app which lets you upload a photo from the browser. When using this in iOS 6, photos seem to end up in landscape orientation even if they were taken in portrait when uploaded. Should I be doing some server side checks to get the image the right way round or is there some kind of iOS specific attributes/JavaScript I can apply to the upload form to fix this?</p> <p><strong>Update</strong></p> <p>As requested, here's the code I wrote to do this. Pre-requisites are that I'm using PHP and the WideImage library (this is a snippet from a much larger script so you could use something different for image manipulation if you like).</p> <pre><code>// Load Image Into Wide Image $image=WideImage::load(IMG_UPLOAD_DIR.$result['name']); $exif=exif_read_data(IMG_UPLOAD_DIR.$result['name']); $orientation=$exif['Orientation']; $result['orientation']=$orientation; // Use Wide Image To Resize Images $full=$image-&gt;resize(IMG_FULL_H,IMG_FULL_H); $thumb=$image-&gt;resize(IMG_THUMB_W,IMG_THUMB_H); switch($orientation){ case 2: $full-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 3: $full-&gt;rotate(-180)-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(-180)-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 4: $full-&gt;rotate(180)-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(180)-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 5: $full-&gt;rotate(90)-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(90)-&gt;mirror()-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 6: $full-&gt;rotate(90)-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(90)-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 7: $full-&gt;rotate(-90)-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(-90)-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; case 8: $full-&gt;rotate(-90)-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;rotate(-90)-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; default: $full-&gt;saveToFile(IMG_UPLOAD_DIR.$result['name'], 90); $thumb-&gt;saveToFile(IMG_UPLOAD_DIR.$thumbName, 90); break; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload