zwork zwork - 1 year ago 57
HTML Question

<img> unwanted photo rotation

I have an image embedded in a table using HTML5. The image is being rotated automatically 90deg counterclockwise, and there is no CSS being applied, nor Javascript (there used to be, hence the

parameters on some of the tags, but I commented out the
block in the

The image was created by a PHP script w/ Imagick to scale it down from the original image, but the original image still had the same problem.


<th>$username has sent you a photo!</th>
<img src="IMG_1314_MOD.jpg" width="300" height="225" class="rotate90"/>
<td><div class="caption">$caption</div></td>

I tried using the CSS code in this answer and applied it to the
, but when it rotated, it didn't adjust the table, and covered up the text.

Does anybody know of a solution to this that I could use?


I used the EXIF extension with PHP to
the EXIF headers on the image, and there didn't seem to be any orientation headers. The headers can be found on Pastebin here if you wouldn't mind double-checking, whoever may read this.

Answer Source

Run jhead -autorot on your JPG image. That's what I do to handle autorotation before putting my images on the web.

This will rotate the image as specified by the camera's orientation sensor, then reset the orientation flag so that it will not be accidentally rotated again.

(Note, I never autorotate my originals, just the scaled versions as part of my script for sending them to the web.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download