I have been trying for quite some time to solve such a code that would do such a thing, but nothing has worked for me so far, and I was able to get all the information from the image except for that, the model of the camera and the lens with which the image was taken and so on, so the most important thing for me right now is to find a fast PHP code solution that knows how to get From the uploaded image the shutter count data.
I would appreciate it if someone could help me with this.
This is my current code:
<?php
if(isset($_POST['submit'])){
$file = $_FILES['file'];
// file details
$fileName = $file['name'];
$fileTmpName = $file['tmp_name'];
$fileSize = $file['size'];
$fileError = $file['error'];
$fileType = $file['type'];
// get the file extension
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
// allowed file types
$allowed = array('jpg', 'jpeg', 'png', 'gif');
if(in_array($fileActualExt, $allowed)){
if($fileError === 0){
if($fileSize < 10000000){
// generate a unique filename to prevent overwriting
$fileNameNew = uniqid('', true)."".$fileActualExt;
$fileDestination = 'uploads/'.$fileNameNew;
// move the file to the upload directory
move_uploaded_file($fileTmpName, $fileDestination);
// extract the camera click count from the EXIF metadata
$exif = geolocation_read_data($fileDestination);
if(isset($exif['ShutterCount']['0x00a7'])){
$clickCount = $exif['ShutterCount']['0x00a7'];
} else {
$clickCount = "N/A";
}
// display the image and the camera click count
echo "<img src='$fileDestination' alt='uploaded image' width='300'><br>";
echo "Camera click count: $clickCount";
} else {
echo "Your file is too big!";
}
} else {
echo "There was an error uploading your file!";
}
} else {
echo "You cannot upload files of this type!";
}
}
echo "<pre>";
print_r($exif);
echo "</pre>";
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit" name="submit">Upload</button>
</form>
Is this the complete program?
Note that only a few camera models store shutter count information.
Does it exist in the file you are using? (Run ExifTool on the file directly to see.)
- Phil
Doesn't the shutter count (and similar) tags only appear in MakerNotes? I have doubts about any generic library having the ability to parse the many varieties of MakerNotes.
Quote from: StarGeek on March 27, 2023, 11:43:35 AMDoesn't the shutter count (and similar) tags only appear in MakerNotes?
Yes.