Reputation: 889
I have been trying to display some basic EXIF data from a photo with no luck. My code is below. I just need to display a few basic pieces of information. I have EXIF enabled on the server and I know this image has EXIF data in there - but no data shows up with this set up. Can anyone tell me what I am doing wrong here?
$exif_data = exif_read_data("http://www.findexif.com/client/samples/swiss_house.jpg");
$emake = $exif_data['Make'];
$emodel = $exif_data['Model'];
$eexposuretime = $exif_data['ExposureTime'];
$efnumber = $exif_data['FNumber'];
$eiso = $exif_data['ISOSpeedRatings'];
$edate = $exif_data['DateTime'];
echo "Make: ". $emake . "<br>";
echo "Model: ". $emodel . "<br>";
echo "Exp: ". $eexposuretime . "<br>";
echo "Date: ". $edate . "<br>";
echo "ISO: ". $eiso . "<br>";
Upvotes: 0
Views: 2051
Reputation: 2289
The filename of exif_read_data
cannot be an URL.
If you still want to read EXIF data of external image, you need to download it first:
<?php
$imageURL = 'http://www.findexif.com/client/samples/swiss_house.jpg';
$localURL = '/tmp/swiss_house.jpeg';
// Use 'copy' function if you have PHP5
// and the HTTP stream wrapper enabled on your server.
copy($imageURL, $localURL);
/**
* This way if you don't have PHP5
$fp = fopen($localURL, 'w');
fwrite($fp, file_get_contents($imageURL));
fclose($fp);
*/
$exif_data = exif_read_data($localURL);
$emake = $exif_data['Make'];
$emodel = $exif_data['Model'];
$eexposuretime = $exif_data['ExposureTime'];
$efnumber = $exif_data['FNumber'];
$eiso = $exif_data['ISOSpeedRatings'];
$edate = $exif_data['DateTime'];
echo 'Make: '. $emake . '<br>';
echo 'Model: '. $emodel . '<br>';
echo 'Exp: '. $eexposuretime . '<br>';
echo 'Date: '. $edate . '<br>';
echo 'ISO: '. $eiso . '<br>';
Upvotes: 5