Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In order to do that, you must read the EXIF information out of the JPEG file. You can either do that with <a href="http://php.net/exif" rel="noreferrer"><code>exif</code></a> PHP extension or with <a href="http://pel.sourceforge.net/" rel="noreferrer"><code>PEL</code></a>.</p> <p>Basically, you have to read the <code>Orientation</code> flag in the file. Here is an example using the <a href="http://php.net/exif" rel="noreferrer"><code>exif</code></a> PHP extension and <a href="http://wideimage.sourceforge.net/" rel="noreferrer"><code>WideImage</code></a> for image manipulation.</p> <pre><code>&lt;?php $exif = exif_read_data($filename); $ort = $exif['Orientation']; $image = WideImage::load($filename); // GD doesn't support EXIF, so all information is removed. $image-&gt;exifOrient($ort)-&gt;saveToFile($filename); class WideImage_Operation_ExifOrient { /** * Rotates and mirrors and image properly based on current orientation value * * @param WideImage_Image $img * @param int $orientation * @return WideImage_Image */ function execute($img, $orientation) { switch ($orientation) { case 2: return $img-&gt;mirror(); break; case 3: return $img-&gt;rotate(180); break; case 4: return $img-&gt;rotate(180)-&gt;mirror(); break; case 5: return $img-&gt;rotate(90)-&gt;mirror(); break; case 6: return $img-&gt;rotate(90); break; case 7: return $img-&gt;rotate(-90)-&gt;mirror(); break; case 8: return $img-&gt;rotate(-90); break; default: return $img-&gt;copy(); } } } </code></pre>
 

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