Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 784
Gan Avatar asked May 21 '14 05:05

Gan


People also ask

What are imported photos on iPhone?

It is showing you all photos in your library stored by the date they have added to your library. This may differ from the All Photos album, where you are seeing the photos sorted by the date they have been taken. You cannot remove the "imports" album.

Does camera roll include videos?

Apple designed the iPhone, iPad and iPod touch Camera Roll (Recents in iOS 13 and above) to only contain photos and videos you take with the device. The same holds true for default albums such as Favourites, Panoramas, Selfies, Screenshots and Videos.

Can iPhone identify a picture?

Open a photo that contains an item you think could be identified, such as a book or painting. Tap the Info icon at the top or bottom of the screen. If Visual Lookup can identify the item, a Look Up option appears on the Info screen, while an icon related to the image pops up in the center of that image.


1 Answers

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;
}
}

?>

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.

like image 139
azbrun Avatar answered Nov 15 '22 20:11

azbrun