Printing result of calculation
I had a problem posted earlier regarding the conversion of EXIF GPS data from Degrees to Decimal.

I have now figured an answer but have one issue left - printing it.

Here you can see the results

http://ukf.com/easyexif/easyexif3.php (note the converted gps data in the top left of the screen above the image).

What I need is to print the data in the correct position in the form box under the headings Decimal Longitude and Decimal Latitude.

Here is the script that returns the above web page:

        <?
        // +++++++++++++++++++++++++ //
        // +++++++ GPS EXIF +++++++ //
        // +++++++++++++++++++++++++ //
        
        // --- Change the 'image1.jpg' value below to the path of your file. --- //
        $Image = 'image1.jpg';
        
        // --- The EXIF GPS Conversion Degrees to Decimal --- //
        
        $exif = exif_read_data($Image, 0, true);
        
        function toDecimal($deg, $min, $sec, $hemi) {
         $d = $deg + $min/60 + $sec/3600;
         return ($hemi=='S' || $hemi=='W') ? $d*=-1 : $d;
        }
        
        function divide($a) {
         $e = explode('/', $a);
         if (!$e[0] || !$e[1]) {
          return 0;
         } else {
          return $e[0] / $e[1];
         }
        }
        
        function getGPS() {
         global $exif;
         if ($exif) {  $lat = $exif['GPS']['GPSLatitude'];
         $log = $exif['GPS']['GPSLongitude'];
          if (!$lat || !$log) return null;
          $lat_degrees = divide($lat[0]);
          $lat_minutes = divide($lat[1]);
          $lat_seconds = divide($lat[2]);
          $lat_hemi = $exif['GPS']['GPSLatitudeRef'];
          $log_degrees = divide($log[0]);
          $log_minutes = divide($log[1]);
          $log_seconds = divide($log[2]);
          $log_hemi = $exif['GPS']['GPSLongitudeRef'];
          $lat_decimal = toDecimal($lat_degrees, $lat_minutes, $lat_seconds, $lat_hemi);
          $log_decimal = toDecimal($log_degrees, $log_minutes, $log_seconds, $log_hemi);
          return array($lat_decimal, $log_decimal);
         } else{
          return null;
         }
        }

        $gps = getGPS();
             $str .= "DecimalLatitude: " . $gps[0] . "<br>\n";
             $str .= "DecimalLongitude: " . $gps[1] . "<br>\n";
             $str .= "\n  </div></td>\n";
             $str .= " </tr>\n";
             echo $str;
        
        // --- The EXIF read command --- //
        $ReadEXIFData = read_exif_data($Image, 0, true);


        // +++++++++++++++++++++++ //
        // +++ GPS COORDINATES +++ //
        // +++++++++++++++++++++++ //

        // --- Decimal Latitude goes here --- //
        // $GPSDECLON = $gps[0]
        
        // --- Decimal Longitude goes here --- //
        // $GPSDECLON = $gps[1]
        
        ?>
        
        <html>
        <head>
        <title>.: GPS EXIF :.</title>
        <style>
        	body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; text-align:         left; background-image: url('background.jpg'); }
        	p { font-family: Helvetica Neue, Geneva, Arial, Verdana; font-size: 10px; letter-spacing: 1px;         font-weight: normal; color: #303030; margin-bottom: 0px; margin-top: 0px; }
        	#Header { position: relative; height: 50px; width: 100%; margin-top: 20px; margin-bottom: 0px; }
        	.HeaderBox { position: absolute; width: 800px; height: 50px; top: 0px; left: 50%;         margin-left:         -400px; z-index: 0; overflow: hidden; font-family: Helvetica Neue, Geneva, Arial, Verdana;         font-size: 36px; letter-spacing: 1px; font-weight: normal; color: #f3f3f3; }
        	#Image { position: relative; height: 400px; width: 100%; margin-top: 20px; margin-bottom: 0px; }
        	.ImageBox { position: absolute; width: 800px; height: 400px; top: 0px; left: 50%; margin-left:         -400px; z-index: 0; overflow: hidden; background-image: url('box_image.gif'); }
        	.ImageShow { float: left; width:780px; height:380; margin-left: 10px; margin-top: 10px; }
        	#Exif { position: relative; height: 260px; width: 100%; margin-top: 20px; margin-bottom: 20px; }
        	.ExifBox { position: absolute; width: 800px; height: 260px; top: 0px; left: 50%; margin-left:         -400px; z-index: 0; overflow: hidden; background-image: url('box_exif.gif'); }
        	.ExifBoxTable { position: absolute; width: 800px; height: 240px; top: 20px; left: 50%;                 margin-left: -400px; z-index: 0; overflow: hidden; }
        </style>
        </head>
        <body>
	
        <div id="Header">
        <div class="HeaderBox">
        	GPS EXIF
        </div>
        </div>
        
                
        <div id="Image">
        <div class="ImageBox">
        <div class="ImageShow">
        	<img src="<? echo $Image ?>	" border="0" />
        </div>
        </div>	
        </div>
        
        
        <div id="Exif">
        <div class="ExifBox">
        <div class="ExifBoxTable" align="center">
	<table width="760px" cellpadding="0" cellspacing="0">
        		<tr>
        			<td width="30%"><p><strong>FILE INFO</strong></p></td>
        			<td width="30%"><p><strong>IMAGE INFO</strong></p></td>
        			<td width="40%"><p><strong>CAMERA INFO</strong></p></td>
        		</tr>
        		
        		<tr>
        			<td width="30%" valign="top">
        			<p>Filename:</p>
        			<p><? echo $Filename; ?></p>
        			<br />
        			<p>File Size</p>
        			<p><? echo $ImageFileSize; ?></p>
        			<br />
        			<p>Width</p>
        			<p><? echo $FileWidth; ?></p>
        			<br />
        			<p>Height</p>
        			<p><? echo $FileHeight; ?></p>
        			</td>
        			
        			<td width="30%" valign="top">
        			<p>Date Taken</p>
        			<p><? echo $DateTaken; ?></p>
        			<br />
        			<p>Shutter Speed</p>
        			<p><? echo $ShutterSpeed; ?></p>
        			<br />
        			<p>ISO</p>
        			<p><? echo $ISO; ?></p>
        			<br />
        			<p>Aperture/F-Stop</p>
        			<p><? echo $FNumber; ?></p>
        			<br />
        			<p>Focal Length</p>
        			<p><? echo $FocalLength; ?></p>
        			</td>
        			
        			<td width="40%" valign="top">
        			<p>Camera Make</p>
        			<p><? echo $CameraMake; ?></p>
        			<br />
        			<p>Camera Model</p>
        			<p><? echo $CameraModel; ?></p>
        			<br />
        			<p>Copyright Info</p>
        			<p><? echo $Copyright; ?></p>
        			<br />
        			<p>Lens</p>
        			<p><? echo $Lens; ?></p>
        			<br />
        			<p>Owner</p>
        			<p><? echo $Owner; ?></p>	
        			</td>
        		</tr>
        	</table>
        </div>
        </div>
        </div>
        <div id="Exif">
        <div class="ExifBox">
        <div class="ExifBoxTable" align="center">
        	<table width="760px" cellpadding="0" cellspacing="0">
        		<tr>
        			
        			<td width="30%"><p><strong>GPS LONGDITUDE</strong></p></td>
        			<td width="40%"><p><strong>GPS LATITUDE</strong></p></td>
        		</tr>
        		
        		<tr>
        			
        			
        			<td width="30%" valign="top">
        			
        			<p>Decimal Longitude</p>
        			<p><? echo $GPSDECLON; ?></p>
        			</td>
        			
        			<td width="40%" valign="top">
        			
        			<p>Decimal Latitude</p>
        			<p><? echo $GPSDECLAT; ?></p>
			</td>
        		</tr>
        	</table>
                </div>
        </div>
        </div>

        
        </body>
        </html>

I thought that as the converted values were in the 'array' $gps I could call them as I show in the commented out lines 71 and 75, but I am obviously wrong as this returns errors ( Fatal error: Function name must be a string ).

Can someone enlighten me as to how I can return the calculated $lat_decimal and $log_decimal values and print them in the correct place (lines 195 and 201 and in returning them for printing, have them in such a format such that in a later version of the script I can add them to a SQLdatabase.

Thanks


 
Printing result of calculation
===

I had a problem posted earlier regarding the conversion of EXIF GPS data from Degrees to Decimal.

I have now figured an answer but have one issue left - printing it.

Here you can see the results

http://ukf.com/easyexif/easyexif3.php (note the converted gps data in the top left of the screen above the image).

What I need is to print the data in the correct position in the form box under the headings Decimal Longitude and Decimal Latitude.

Here is the script that returns the above web page:

        <?
        // +++++++++++++++++++++++++ //
        // +++++++ GPS EXIF +++++++ //
        // +++++++++++++++++++++++++ //
        
        // --- Change the 'image1.jpg' value below to the path of your file. --- //
        $Image = 'image1.jpg';
        
        // --- The EXIF GPS Conversion Degrees to Decimal --- //
        
        $exif = exif_read_data($Image, 0, true);
        
        function toDecimal($deg, $min, $sec, $hemi) {
         $d = $deg + $min/60 + $sec/3600;
         return ($hemi=='S' || $hemi=='W') ? $d*=-1 : $d;
        }
        
        function divide($a) {
         $e = explode('/', $a);
         if (!$e[0] || !$e[1]) {
          return 0;
         } else {
          return $e[0] / $e[1];
         }
        }
        
        function getGPS() {
         global $exif;
         if ($exif) {  $lat = $exif['GPS']['GPSLatitude'];
         $log = $exif['GPS']['GPSLongitude'];
          if (!$lat || !$log) return null;
          $lat_degrees = divide($lat[0]);
          $lat_minutes = divide($lat[1]);
          $lat_seconds = divide($lat[2]);
          $lat_hemi = $exif['GPS']['GPSLatitudeRef'];
          $log_degrees = divide($log[0]);
          $log_minutes = divide($log[1]);
          $log_seconds = divide($log[2]);
          $log_hemi = $exif['GPS']['GPSLongitudeRef'];
          $lat_decimal = toDecimal($lat_degrees, $lat_minutes, $lat_seconds, $lat_hemi);
          $log_decimal = toDecimal($log_degrees, $log_minutes, $log_seconds, $log_hemi);
          return array($lat_decimal, $log_decimal);
         } else{
          return null;
         }
        }

        $gps = getGPS();
             $str .= "DecimalLatitude: " . $gps[0] . "<br>\n";
             $str .= "DecimalLongitude: " . $gps[1] . "<br>\n";
             $str .= "\n  </div></td>\n";
             $str .= " </tr>\n";
             echo $str;
        
        // --- The EXIF read command --- //
        $ReadEXIFData = read_exif_data($Image, 0, true);


        // +++++++++++++++++++++++ //
        // +++ GPS COORDINATES +++ //
        // +++++++++++++++++++++++ //

        // --- Decimal Latitude goes here --- //
        // $GPSDECLON = $gps[0]
        
        // --- Decimal Longitude goes here --- //
        // $GPSDECLON = $gps[1]
        
        ?>
        
        <html>
        <head>
        <title>.: GPS EXIF :.</title>
        <style>
        	body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; text-align:         left; background-image: url('background.jpg'); }
        	p { font-family: Helvetica Neue, Geneva, Arial, Verdana; font-size: 10px; letter-spacing: 1px;         font-weight: normal; color: #303030; margin-bottom: 0px; margin-top: 0px; }
        	#Header { position: relative; height: 50px; width: 100%; margin-top: 20px; margin-bottom: 0px; }
        	.HeaderBox { position: absolute; width: 800px; height: 50px; top: 0px; left: 50%;         margin-left:         -400px; z-index: 0; overflow: hidden; font-family: Helvetica Neue, Geneva, Arial, Verdana;         font-size: 36px; letter-spacing: 1px; font-weight: normal; color: #f3f3f3; }
        	#Image { position: relative; height: 400px; width: 100%; margin-top: 20px; margin-bottom: 0px; }
        	.ImageBox { position: absolute; width: 800px; height: 400px; top: 0px; left: 50%; margin-left:         -400px; z-index: 0; overflow: hidden; background-image: url('box_image.gif'); }
        	.ImageShow { float: left; width:780px; height:380; margin-left: 10px; margin-top: 10px; }
        	#Exif { position: relative; height: 260px; width: 100%; margin-top: 20px; margin-bottom: 20px; }
        	.ExifBox { position: absolute; width: 800px; height: 260px; top: 0px; left: 50%; margin-left:         -400px; z-index: 0; overflow: hidden; background-image: url('box_exif.gif'); }
        	.ExifBoxTable { position: absolute; width: 800px; height: 240px; top: 20px; left: 50%;                 margin-left: -400px; z-index: 0; overflow: hidden; }
        </style>
        </head>
        <body>
	
        <div id="Header">
        <div class="HeaderBox">
        	GPS EXIF
        </div>
        </div>
        
                
        <div id="Image">
        <div class="ImageBox">
        <div class="ImageShow">
        	<img src="<? echo $Image ?>	" border="0" />
        </div>
        </div>	
        </div>
        
        
        <div id="Exif">
        <div class="ExifBox">
        <div class="ExifBoxTable" align="center">
	<table width="760px" cellpadding="0" cellspacing="0">
        		<tr>
        			<td width="30%"><p><strong>FILE INFO</strong></p></td>
        			<td width="30%"><p><strong>IMAGE INFO</strong></p></td>
        			<td width="40%"><p><strong>CAMERA INFO</strong></p></td>
        		</tr>
        		
        		<tr>
        			<td width="30%" valign="top">
        			<p>Filename:</p>
        			<p><? echo $Filename; ?></p>
        			<br />
        			<p>File Size</p>
        			<p><? echo $ImageFileSize; ?></p>
        			<br />
        			<p>Width</p>
        			<p><? echo $FileWidth; ?></p>
        			<br />
        			<p>Height</p>
        			<p><? echo $FileHeight; ?></p>
        			</td>
        			
        			<td width="30%" valign="top">
        			<p>Date Taken</p>
        			<p><? echo $DateTaken; ?></p>
        			<br />
        			<p>Shutter Speed</p>
        			<p><? echo $ShutterSpeed; ?></p>
        			<br />
        			<p>ISO</p>
        			<p><? echo $ISO; ?></p>
        			<br />
        			<p>Aperture/F-Stop</p>
        			<p><? echo $FNumber; ?></p>
        			<br />
        			<p>Focal Length</p>
        			<p><? echo $FocalLength; ?></p>
        			</td>
        			
        			<td width="40%" valign="top">
        			<p>Camera Make</p>
        			<p><? echo $CameraMake; ?></p>
        			<br />
        			<p>Camera Model</p>
        			<p><? echo $CameraModel; ?></p>
        			<br />
        			<p>Copyright Info</p>
        			<p><? echo $Copyright; ?></p>
        			<br />
        			<p>Lens</p>
        			<p><? echo $Lens; ?></p>
        			<br />
        			<p>Owner</p>
        			<p><? echo $Owner; ?></p>	
        			</td>
        		</tr>
        	</table>
        </div>
        </div>
        </div>
        <div id="Exif">
        <div class="ExifBox">
        <div class="ExifBoxTable" align="center">
        	<table width="760px" cellpadding="0" cellspacing="0">
        		<tr>
        			
        			<td width="30%"><p><strong>GPS LONGDITUDE</strong></p></td>
        			<td width="40%"><p><strong>GPS LATITUDE</strong></p></td>
        		</tr>
        		
        		<tr>
        			
        			
        			<td width="30%" valign="top">
        			
        			<p>Decimal Longitude</p>
        			<p><? echo $GPSDECLON; ?></p>
        			</td>
        			
        			<td width="40%" valign="top">
        			
        			<p>Decimal Latitude</p>
        			<p><? echo $GPSDECLAT; ?></p>
			</td>
        		</tr>
        	</table>
                </div>
        </div>
        </div>

        
        </body>
        </html>

I thought that as the converted values were in the 'array' $gps I could call them as I show in the commented out lines 71 and 75, but I am obviously wrong as this returns errors ( Fatal error: Function name must be a string ).

Can someone enlighten me as to how I can return the calculated $lat_decimal and $log_decimal values and print them in the correct place (lines 195 and 201 and in returning them for printing, have them in such a format such that in a later version of the script I can add them to a SQLdatabase.

Thanks


 