如何检测照片/视频是从相机拍摄还是从iphone safari中的相机胶卷导入 [英] How to detect whether photo/video was taken from camera or imported from camera roll in iphone safari

查看:177
本文介绍了如何检测照片/视频是从相机拍摄还是从iphone safari中的相机胶卷导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个文件输入标签来上传照片/视频。
当网站在移动Safari浏览器中打开,并且当我们点击文件输入时,一个操作表打开,有3个选项拍照或视频选择Existing 取消
有没有办法在js中确定文件是从相机拍摄的(拍摄照片或视频)或导入的(选择现有的)从相机胶卷?

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 up with 3 options take photo or Video, choose Existing and cancel. Is there anyway to determine in js that the file was taken from camera(take photo or video), or imported(choose existing) from camera roll ?

推荐答案

我有一个php解决方案实现了这个,我不确定这会对你有帮助,但是这里是代码:

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

<?php

$camera = cameraUsed("C:\Users\Ale\Pictures\sep7imodia.jpg");
echo "Camera Used: " . $camera['make'] . " " . $camera['model'] . "<br />";
echo "Exposure Time: " . $camera['exposure'] . "<br />";
echo "Aperture: " . $camera['aperture'] . "<br />";
echo "ISO: " . $camera['iso'] . "<br />";
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;
}
}

?>

您可以将$ camera ['date']的值与实际的日期时间进行比较,if有几秒钟的差异,你可以假设它刚刚被电话拿走。

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.

这篇关于如何检测照片/视频是从相机拍摄还是从iphone safari中的相机胶卷导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆