Exemple #1
0
 /**
  * Extract EXIF Data from image
  *
  * @warning image file must be saved first
  */
 public function extractExifData()
 {
     elgg_load_library('tidypics:exif');
     td_get_exif($this);
 }
Exemple #2
0
 /**
  * Extract EXIF Data from image
  *
  * @warning image file must be saved first
  */
 public function extractExifData()
 {
     include_once dirname(dirname(__FILE__)) . "/lib/exif.php";
     td_get_exif($this);
 }
 $file->write();
 $file->write(get_uploaded_file($key));
 $file->close();
 */
 $result = $file->save();
 if (!$result) {
     array_push($not_uploaded, $sent_file['name']);
     array_push($error_msgs, elgg_echo('tidypics:save_error'));
     continue;
 }
 //add tags
 create_metadata($file->guid, "tags", $photo["tags"], "text", $user->guid, ACCESS_PUBLIC);
 //add title and description
 create_object_entity($file->guid, $photo["title"], $photo["description"]);
 //get and store the exif data
 td_get_exif($file);
 // resize photos to create thumbnails
 if ($image_lib == 'ImageMagick') {
     // ImageMagick command line
     if (tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) != true) {
         trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING);
     }
 } else {
     if ($image_lib == 'ImageMagickPHP') {
         // imagick php extension
         if (tp_create_imagick_thumbnails($file, $prefix, $filestorename) != true) {
             trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING);
         }
     } else {
         if (tp_create_gd_thumbnails($file, $prefix, $filestorename) != true) {
             trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING);
Exemple #4
0
/**
 * Grab array of EXIF data for display
 * 
 * @param int $file_guid GUID of TidypicsImage
 * @return array|false
 */
function tp_exif_formatted($file_guid)
{
    $metadata_exif = get_metadata_byname($file_guid, "tp_exif");
    if (!$metadata_exif) {
        // //try to load it from the file if its not in the database
        $file = new ElggFile($file_guid);
        td_get_exif($file);
        unset($file);
        $metadata_exif = get_metadata_byname($file_guid, "tp_exif");
    }
    if (!$metadata_exif) {
        return false;
    }
    $exif = unserialize($metadata_exif["value"]);
    $model = $exif['Model'];
    if (!$model) {
        $model = "N/A";
    }
    $exif_data['Model'] = $model;
    $exposure = $exif['ExposureTime'];
    if (!$exposure) {
        $exposure = "N/A";
    }
    $exif_data['Shutter'] = $exposure;
    //got the code snippet below from http://www.zenphoto.org/support/topic.php?id=17
    //convert the raw values to understandible values
    $Fnumber = explode("/", $exif['FNumber']);
    if ($Fnumber[1] != 0) {
        $Fnumber = $Fnumber[0] / $Fnumber[1];
    } else {
        $Fnumber = 0;
    }
    if (!$Fnumber) {
        $Fnumber = "N/A";
    } else {
        $Fnumber = "f/{$Fnumber}";
    }
    $exif_data['Aperture'] = $Fnumber;
    $iso = $exif['ISOSpeedRatings'];
    if (!$iso) {
        $iso = "N/A";
    }
    $exif_data['ISO Speed'] = $iso;
    $Focal = explode("/", $exif['FocalLength']);
    if ($Focal[1] != 0) {
        $Focal = $Focal[0] / $Focal[1];
    } else {
        $Focal = 0;
    }
    if (!$Focal || round($Focal) == "0") {
        $Focal = 0;
    }
    if (round($Focal) == 0) {
        $Focal = "N/A";
    } else {
        $Focal = round($Focal) . "mm";
    }
    $exif_data['Focal Length'] = $Focal;
    $captured = $exif['DateTime'];
    if (!$captured) {
        $captured = "N/A";
    }
    $exif_data['Captured'] = $captured;
    return $exif_data;
}