Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Server-side Scripting _ Incorrect image rotation Firefox, Chrome & Safari

Posted by: spruce18b @hotmail.com May 13 2020, 03:20 PM

I uploaded my php file with image names in HTML code to my Web site. They were correctly rotated when I viewed them with Firefox but some of the images (portrait and landscape) were incorrectly rotated when I viewed them with Chrome or Safari. The conflicts thus occurred across operating systems and across Web browsers.

I need to modify the PHP code to enable viewers on all platforms to see the images in the correct orientation. Could someone please assist a PHP novice? My PHP file is shown below.

Thanks

spruce18b

<?php
##########################################################################
$password = "hello"; // Modify Password to suit for access, Max 10 Char.
##########################################################################
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Title Los Angeles 2020.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
P { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
TD { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
-->
</style>
</head>
<body>
<?php
print "<h2 align=\"center\">Title Los Angeles 2020</h2>";
// If password is valid let the user get access
if (isset($_POST["password"]) && ($_POST["password"]=="$password")) {
?>
<!-- START OF HIDDEN HTML - PLACE YOUR CONTENT HERE -->
<html>
<head>
<title>Title Los Angeles 2020</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style4 {
font-size: 36px;
color: #0033FF;
}
-->
</style>
<style type="text/css">
<!--
.style2 {
font-size: 20px;
color: #0033FF;
}
-->
</style>
</head>
<body>
<p class="style4">Title Los Angeles 2020</p>
<p class="style2"></p>

<table width="600" border="0"cellpadding="0" cellspacing="0">


<tr><td>
<img src=DSC999.JPG width="450 " height="600 "></td></tr><tr>
<td width="600 " style="color:blue">Caption <br/><br/></td><td width="600 "allign="right"> 14 <br/><br/></td></tr>


</body>
</html>

<!-- END OF HIDDEN HTML -->
<?php
}
else
{
// Wrong password or no password entered display this message
if (isset($_POST['password']) || $password == "") {
print "<p align=\"center\"><font color=\"red\"><b>Incorrect Password</b><br>Please enter the correct password</font></p>";}
print "<form method=\"post\"><p align=\"center\">Please enter your password for access<br>";
print "<input name=\"password\" type=\"password\" size=\"25\" maxlength=\"10\"><input value=\"Login\" type=\"submit\"></p></form>";
}
print "<br><br>";
?>
<BR>
</body>
</html>




Posted by: CharlesEF May 13 2020, 03:47 PM

1st thing I would try is fixing your HTML code. Your HTML document is invalid. You have 2 <head>, <body>, etc. There should only be 1 of each.

Posted by: Christian J May 13 2020, 04:02 PM

QUOTE(spruce18b @hotmail.com @ May 13 2020, 10:20 PM) *

I uploaded my php file with image names in HTML code to my Web site. They were correctly rotated when I viewed them with Firefox but some of the images (portrait and landscape) were incorrectly rotated when I viewed them with Chrome or Safari. The conflicts thus occurred across operating systems and across Web browsers.

Maybe there's something wrong with the image file? I see nothing in the code example that could cause this.

However, the PHP code seems to print the HTML code of a web page inside another one, which is invalid (you can only have one HTML, HEAD and BODY section in a page).

Posted by: pandy May 13 2020, 04:28 PM

Is the image a photo? Image rotation is a mess. Here's a bit about it (first I found, there are probably lots of other pages about the matter).
https://www.howtogeek.com/254830/why-your-photos-dont-always-appear-correctly-rotated/

I've noticed that on some sites where users can upload photos they turn out wrong quite often and on others it never happens. I guess it has to do with the scripts the sites use. I've also noticed that most often an image that's rotated wrong on the page shows up as it should if I view it directly in the browser.

Posted by: pandy May 13 2020, 05:35 PM

I see now that your script doesn't touch the image. So my theory, right as it may be, doesn't apply.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)