How to detect whether photo/video was taken from camera or imported from camera roll in iphone safari

后端 未结 1 679
后悔当初
后悔当初 2021-02-14 15:26

In my website I have a file input tag to upload photo/video. When the website is opened in mobile safari, and when we click on the file input, an Action sheet opens

1条回答
  •  醉梦人生
    2021-02-14 15:50

    I've a php solution implemented from this, I'm not sure that that's going to help you, but here is the code:

    ";
    echo "Exposure Time: " . $camera['exposure'] . "
    "; echo "Aperture: " . $camera['aperture'] . "
    "; echo "ISO: " . $camera['iso'] . "
    "; echo "Date Taken: " . $camera['date']; // This function is used to determine the camera details for a specific image. It returns an array with the parameters. function cameraUsed($imagePath) { // Check if the variable is set and if the file itself exists before continuing if ((isset($imagePath)) and (file_exists($imagePath))) { // There are 2 arrays which contains the information we are after, so it's easier to state them both $exif_ifd0 = read_exif_data($imagePath ,'IFD0' ,0); $exif_exif = read_exif_data($imagePath ,'EXIF' ,0); //error control $notFound = "Unavailable"; // Make if (@array_key_exists('Make', $exif_ifd0)) { $camMake = $exif_ifd0['Make']; } else { $camMake = $notFound; } // Model if (@array_key_exists('Model', $exif_ifd0)) { $camModel = $exif_ifd0['Model']; } else { $camModel = $notFound; } // Exposure if (@array_key_exists('ExposureTime', $exif_ifd0)) { $camExposure = $exif_ifd0['ExposureTime']; } else { $camExposure = $notFound; } // Aperture if (@array_key_exists('ApertureFNumber', $exif_ifd0['COMPUTED'])) { $camAperture = $exif_ifd0['COMPUTED']['ApertureFNumber']; } else { $camAperture = $notFound; } // Date if (@array_key_exists('DateTime', $exif_ifd0)) { $camDate = $exif_ifd0['DateTime']; } else { $camDate = $notFound; } // ISO if (@array_key_exists('ISOSpeedRatings',$exif_exif)) { $camIso = $exif_exif['ISOSpeedRatings']; } else { $camIso = $notFound; } $return = array(); $return['make'] = $camMake; $return['model'] = $camModel; $return['exposure'] = $camExposure; $return['aperture'] = $camAperture; $return['date'] = $camDate; $return['iso'] = $camIso; return $return; } else { return false; } } ?>

    You can take the $camera['date'] value to compare with the actual datetime, and if there are a few seconds difference, you can assume it was taken by the phone just now.

    0 讨论(0)
提交回复
热议问题