本文整理汇总了PHP中extract_exif_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP extract_exif_comment函数的具体用法?PHP extract_exif_comment怎么用?PHP extract_exif_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extract_exif_comment函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ProcessFolder
//.........这里部分代码省略.........
# Save the value
#print_r($path_parts);
$value = $path_parts[$level - 1];
if ($staticsync_extension_mapping_append_values) {
$given_value = $value;
// append the values if possible...not used on dropdown, date, categroy tree, datetime, or radio buttons
$field_info = get_resource_type_field($field);
if (in_array($field['type'], array(0, 1, 2, 4, 5, 6, 7, 8))) {
$old_value = sql_value("select value value from resource_data where resource={$r} and resource_type_field={$field}", "");
$value = append_field_value($field_info, $value, $old_value);
}
}
update_field($r, $field, trim($value));
if (strtotime(trim($value))) {
add_keyword_mappings($r, trim($value), $field, false, true);
} else {
add_keyword_mappings($r, trim($value), $field);
}
if ($staticsync_extension_mapping_append_values) {
$value = $given_value;
}
echo " - Extracted metadata from path: {$value}" . PHP_EOL;
}
}
}
}
}
}
#Resize only original images.
if (!word_in_string($exclude_resize, explode('/', $fullpath))) {
echo "Creating preview..";
create_previews($r, false, $extension, false, false, -1, false, $staticsync_ingest);
}
# update access level
sql_query("UPDATE resource SET access = '{$accessval}',archive='{$staticsync_defaultstate}' WHERE ref = '{$r}'");
# Add any alternative files
$altpath = $fullpath . $staticsync_alternatives_suffix;
if ($staticsync_ingest && file_exists($altpath)) {
$adh = opendir($altpath);
while (($altfile = readdir($adh)) !== false) {
$filetype = filetype($altpath . "/" . $altfile);
if ($filetype == "file" && substr($file, 0, 1) != "." && strtolower($file) != "thumbs.db") {
# Create alternative file
# Find extension
$ext = explode(".", $altfile);
$ext = $ext[count($ext) - 1];
$description = str_replace("?", strtoupper($ext), $lang["originalfileoftype"]);
$file_size = filesize_unlimited($altpath . "/" . $altfile);
$aref = add_alternative_file($r, $altfile, $description, $altfile, $ext, $file_size);
$path = get_resource_path($r, true, '', true, $ext, -1, 1, false, '', $aref);
rename($altpath . "/" . $altfile, $path);
# Move alternative file
}
}
}
# Add to collection
if ($staticsync_autotheme) {
$test = '';
$test = sql_query("SELECT * FROM collection_resource WHERE collection='{$collection}' AND resource='{$r}'");
if (count($test) == 0) {
sql_query("INSERT INTO collection_resource (collection, resource, date_added)\n VALUES ('{$collection}', '{$r}', NOW())");
}
}
} else {
# Import failed - file still being uploaded?
echo " *** Skipping file - it was not possible to move the file (still being imported/uploaded?)" . PHP_EOL;
}
} else {
# check modified date and update previews if necessary
$filemod = filemtime($fullpath);
if (array_key_exists($shortpath, $modtimes) && $filemod > strtotime($modtimes[$shortpath])) {
# File has been modified since we last created previews. Create again.
$rd = sql_query("SELECT ref, has_image, file_modified, file_extension FROM resource\n WHERE file_path='" . escape_check($shortpath) . "'");
if (count($rd) > 0) {
$rd = $rd[0];
$rref = $rd["ref"];
echo "Resource {$rref} has changed, regenerating previews: {$fullpath}" . PHP_EOL;
extract_exif_comment($rref, $rd["file_extension"]);
# extract text from documents (e.g. PDF, DOC).
global $extracted_text_field;
if (isset($extracted_text_field)) {
if (isset($unoconv_path) && in_array($extension, $unoconv_extensions)) {
// omit, since the unoconv process will do it during preview creation below
} else {
extract_text($rref, $extension);
}
}
# Store original filename in field, if set
global $filename_field;
if (isset($filename_field)) {
update_field($rref, $filename_field, $file);
}
create_previews($rref, false, $rd["file_extension"], false, false, -1, false, $staticsync_ingest);
sql_query("UPDATE resource SET file_modified=NOW() WHERE ref='{$rref}'");
}
}
}
}
}
}
示例2: resource_type_config_override
resource_type_config_override($resource["resource_type"]);
// get mp3 paths if necessary and set $use_mp3_player switch
if (!(isset($resource['is_transcoding']) && $resource['is_transcoding'] == 1) && (in_array($resource["file_extension"], $ffmpeg_audio_extensions) || $resource["file_extension"] == "mp3") && $mp3_player) {
$use_mp3_player = true;
} else {
$use_mp3_player = false;
}
if ($use_mp3_player) {
$mp3realpath = get_resource_path($ref, true, "", false, "mp3");
if (file_exists($mp3realpath)) {
$mp3path = get_resource_path($ref, false, "", false, "mp3");
}
}
# Dev feature - regenerate exif data.
if (getval("regenexif", "") != "") {
extract_exif_comment($ref, $resource["file_extension"]);
$resource = get_resource_data($ref, false);
}
# Load access level
$access = get_resource_access($ref);
hook("beforepermissionscheck");
# check permissions (error message is not pretty but they shouldn't ever arrive at this page unless entering a URL manually)
if ($access == 2) {
exit("This is a confidential resource.");
}
hook("afterpermissionscheck");
# Establish if this is a metadata template resource, so we can switch off certain unnecessary features
$is_template = isset($metadata_template_resource_type) && $resource["resource_type"] == $metadata_template_resource_type;
$title_field = $view_title_field;
# If this is a metadata template and we're using field data, change title_field to the metadata template title field
if (isset($metadata_template_resource_type) && $resource["resource_type"] == $metadata_template_resource_type) {
示例3: exit
<?php
# This script is useful for initial imports when you're working out metadata mappings. However, be aware that
# local ResourceSpace field edits could be overwritten by original file metadata during this process.
include "../../include/db.php";
include "../../include/authenticate.php";
if (!checkperm("a")) {
exit("Permission denied");
}
include "../../include/general.php";
include "../../include/resource_functions.php";
include "../../include/image_processing.php";
set_time_limit(60 * 60 * 40);
echo "Updating EXIF/IPTC...";
$rd = sql_query("select ref,file_extension from resource where has_image=1 ");
for ($n = 0; $n < count($rd); $n++) {
$ref = $rd[$n]['ref'];
echo "." . $ref;
extract_exif_comment($rd[$n]['ref'], $rd[$n]['file_extension']);
}
echo "...done.";
示例4: update_resource
function update_resource($r,$path,$type,$title,$ingest=false)
{
# Update the resource with the file at the given path
# Note that the file will be used at it's present location and will not be copied.
global $syncdir,$staticsync_prefer_embedded_title;
update_resource_type($r, $type);
# Work out extension based on path
$extension=explode(".",$path);$extension=trim(strtolower(end($extension)));
# file_path should only really be set to indicate a staticsync location. Otherwise, it should just be left blank.
if ($ingest){$file_path="";} else {$file_path=escape_check($path);}
# Store extension/data in the database
sql_query("update resource set archive=0,file_path='".$file_path."',file_extension='$extension',preview_extension='$extension',file_modified=now() where ref='$r'");
# Store original filename in field, if set
if (!$ingest)
{
# This file remains in situ; store the full path in file_path to indicate that the file is stored remotely.
global $filename_field;
if (isset($filename_field))
{
$s=explode("/",$path);
$filename=end($s);
update_field($r,$filename_field,$filename);
}
}
else
{
# This file is being ingested. Store only the filename.
$s=explode("/",$path);
$filename=end($s);
global $filename_field;
if (isset($filename_field))
{
update_field($r,$filename_field,$filename);
}
# Move the file
global $syncdir;
$destination=get_resource_path($r,true,"",true,$extension);
$result=rename($syncdir . "/" . $path,$destination);
if ($result===false)
{
# The rename failed. The file is possibly still being copied or uploaded and must be ignored on this pass.
# Delete the resouce just created and return false.
delete_resource($r);
return false;
}
chmod($destination,0777);
}
# generate title and extract embedded metadata
# order depends on which title should be the default (embedded or generated)
if ($staticsync_prefer_embedded_title)
{
update_field($r,8,$title);
extract_exif_comment($r,$extension);
} else {
extract_exif_comment($r,$extension);
update_field($r,8,$title);
}
# Ensure folder is created, then create previews.
get_resource_path($r,false,"pre",true,$extension);
# Generate previews/thumbnails (if configured i.e if not completed by offline process 'create_previews.php')
global $enable_thumbnail_creation_on_upload;
if ($enable_thumbnail_creation_on_upload) {create_previews($r,false,$extension);}
# Pass back the newly created resource ID.
return $r;
}
示例5: create_resource
if (!$ref) {
$ref = create_resource(getval("resourcetype", 1), $status, $userref);
}
$path_parts = pathinfo($_FILES['userfile']['name']);
$extension = strtolower($path_parts['extension']);
$filepath = get_resource_path($ref, true, "", true, $extension);
$collection = getvalescaped('collection', "", true);
$result = move_uploaded_file($_FILES['userfile']['tmp_name'], $filepath);
$wait = sql_query("update resource set file_extension='{$extension}',preview_extension='jpg',file_modified=now() ,has_image=0 where ref='{$ref}'");
# Store original filename in field, if set
global $filename_field;
if (isset($filename_field)) {
$wait = update_field($ref, $filename_field, $_FILES['userfile']['name']);
}
// extract metadata
$wait = extract_exif_comment($ref, $extension);
$resource = get_resource_data($ref);
//create previews
if ($camera_autorotation) {
AutoRotateImage($filepath);
}
$wait = create_previews($ref, false, $extension);
// add resource to collection
if ($collection != "") {
$collection_exists = sql_value("select name value from collection where ref='" . escape_check($collection) . "'", "");
if ($collection_exists != "") {
if (!add_resource_to_collection($ref, $collection)) {
header("HTTP/1.0 403 Forbidden.");
echo "HTTP/1.0 403 Forbidden. Collection is not writable by this user.\n";
exit;
}
示例6: ProcessFolder
//.........这里部分代码省略.........
# Save the value
print_r($path_parts);
$value = $path_parts[$level-1];
update_field ($r, $field, $value);
echo " - Extracted metadata from path: $value" . PHP_EOL;
}
}
}
}
}
# update access level
sql_query("UPDATE resource SET access = '$accessval',archive='$staticsync_defaultstate' WHERE ref = '$r'");
# Add any alternative files
$altpath = $fullpath . $staticsync_alternatives_suffix;
if ($staticsync_ingest && file_exists($altpath))
{
$adh = opendir($altpath);
while (($altfile = readdir($adh)) !== false)
{
$filetype = filetype($altpath . "/" . $altfile);
if (($filetype == "file") && (substr($file,0,1) != ".") && (strtolower($file) != "thumbs.db"))
{
# Create alternative file
# Find extension
$ext = explode(".", $altfile);
$ext = $ext[count($ext)-1];
$description = str_replace("?", strtoupper($ext), $lang["originalfileoftype"]);
$file_size = filesize_unlimited($altpath . "/" . $altfile);
$aref = add_alternative_file($r, $altfile, $description, $altfile, $ext, $file_size);
$path = get_resource_path($r, true, '', true, $ext, -1, 1, false, '', $aref);
rename($altpath . "/" . $altfile,$path); # Move alternative file
}
}
}
# Add to collection
if ($staticsync_autotheme)
{
$test = '';
$test = sql_query("SELECT * FROM collection_resource WHERE collection='$collection' AND resource='$r'");
if (count($test) == 0)
{
sql_query("INSERT INTO collection_resource (collection, resource, date_added)
VALUES ('$collection', '$r', NOW())");
}
}
}
else
{
# Import failed - file still being uploaded?
echo " *** Skipping file - it was not possible to move the file (still being imported/uploaded?)" . PHP_EOL;
}
}
else
{
# check modified date and update previews if necessary
$filemod = filemtime($fullpath);
if (array_key_exists($shortpath,$modtimes) && ($filemod > strtotime($modtimes[$shortpath])))
{
# File has been modified since we last created previews. Create again.
$rd = sql_query("SELECT ref, has_image, file_modified, file_extension FROM resource
WHERE file_path='" . escape_check($shortpath) . "'");
if (count($rd) > 0)
{
$rd = $rd[0];
$rref = $rd["ref"];
echo "Resource $rref has changed, regenerating previews: $fullpath" . PHP_EOL;
extract_exif_comment($rref,$rd["file_extension"]);
# extract text from documents (e.g. PDF, DOC).
global $extracted_text_field;
if (isset($extracted_text_field)) {
if (isset($unoconv_path) && in_array($extension,$unoconv_extensions)){
// omit, since the unoconv process will do it during preview creation below
}
else {
extract_text($rref,$extension);
}
}
# Store original filename in field, if set
global $filename_field;
if (isset($filename_field))
{
update_field($rref,$filename_field,$file);
}
create_previews($rref, false, $rd["file_extension"], false, false, -1, false, $staticsync_ingest);
sql_query("UPDATE resource SET file_modified=NOW() WHERE ref='$rref'");
}
}
}
}
}
}
示例7: error_alert
error_alert($error);
exit;
}
# Check edit permission.
if (!get_edit_access($ref, $resource["archive"], false, $resource)) {
# The user is not allowed to edit this resource or the resource doesn't exist.
$error = $lang['error-permissiondenied'];
error_alert($error);
exit;
}
if (getval("regen", "") != "") {
sql_query("update resource set preview_attempts=0 WHERE ref='" . $ref . "'");
create_previews($ref, false, $resource["file_extension"]);
}
if (getval("regenexif", "") != "") {
extract_exif_comment($ref);
}
# Establish if this is a metadata template resource, so we can switch off certain unnecessary features
$is_template = isset($metadata_template_resource_type) && $resource["resource_type"] == $metadata_template_resource_type;
hook("editbeforeheader");
# -----------------------------------
# PERFORM SAVE
# -----------------------------------
if (getval("autosave", "") != "" || getval("tweak", "") == "" && getval("submitted", "") != "" && getval("resetform", "") == "" && getval("copyfromsubmit", "") == "") {
if ($embedded_data_user_select && getval("exif_option", "") == "custom" || isset($embedded_data_user_select_fields)) {
$exif_override = false;
foreach ($_POST as $postname => $postvar) {
if (strpos($postname, "exif_option_") !== false) {
$uploadparams .= "&" . urlencode($postname) . "=" . urlencode($postvar);
$exif_override = true;
}
示例8: ProcessFolder
//.........这里部分代码省略.........
echo "Will set access level to " . $lang['access' . $n] . " ($n)\n";
}
}
} else {
# Save the value
print_r($path_parts);
$value=$path_parts[$level-1];
update_field ($r,$field,$value);
echo " - Extracted metadata from path: $value\n";
}
}
}
}
}
// update access level
sql_query("update resource set access = '$accessval' where ref = '$r'");
# Add any alternative files
$altpath=$fullpath . $staticsync_alternatives_suffix;
if ($staticsync_ingest && file_exists($altpath))
{
$adh=opendir($altpath);
while (($altfile = readdir($adh)) !== false)
{
$filetype=filetype($altpath . "/" . $altfile);
if (($filetype=="file") && (substr($file,0,1)!=".") && (strtolower($file)!="thumbs.db"))
{
# Create alternative file
global $lang;
# Find extension
$ext=explode(".",$altfile);$ext=$ext[count($ext)-1];
$aref = add_alternative_file($r, $altfile, str_replace("?",strtoupper($ext),$lang["originalfileoftype"]), $altfile, $ext, filesize_unlimited($altpath . "/" . $altfile));
$path=get_resource_path($r, true, "", true, $ext, -1, 1, false, "", $aref);
rename ($altpath . "/" . $altfile,$path); # Move alternative file
}
}
}
# Add to collection
if ($staticsync_autotheme)
{
$test="";
$test=sql_query("select * from collection_resource where collection='$collection' and resource='$r'");
if (count($test)==0){
sql_query("insert into collection_resource(collection,resource,date_added) values ('$collection','$r',now())");
}
}
}
else
{
# Import failed - file still being uploaded?
echo " *** Skipping file - it was not possible to move the file (still being imported/uploaded?) \n";
}
}
else
{
# check modified date and update previews if necessary
$filemod=filemtime($fullpath);
if (array_key_exists($shortpath,$modtimes) && ($filemod>strtotime($modtimes[$shortpath])))
{
# File has been modified since we last created previews. Create again.
$rd=sql_query("select ref,has_image,file_modified,file_extension from resource where file_path='" . (escape_check($shortpath)) . "'");
if (count($rd)>0)
{
$rd=$rd[0];
$rref=$rd["ref"];
echo "Resource $rref has changed, regenerating previews: $fullpath\n";
extract_exif_comment($rref,$rd["file_extension"]);
# extract text from documents (e.g. PDF, DOC).
global $extracted_text_field;
if (isset($extracted_text_field)) {
if (isset($unoconv_path) && in_array($extension,$unoconv_extensions)){
// omit, since the unoconv process will do it during preview creation below
}
else {
extract_text($rref,$extension);
}
}
# Store original filename in field, if set
global $filename_field;
if (isset($filename_field))
{
update_field($rref,$filename_field,$file);
}
create_previews($rref,false,$rd["file_extension"]);
sql_query("update resource set file_modified=now() where ref='$rref'");
}
}
}
}
}
}
示例9:
update_field($r,$filename_field,$file['filename']);
update_field($r,$checkmail_subject_field,$subject);
if ($body_html!='' && $checkmail_html){
update_field($r,$checkmail_body_field,$body_html);
} else {
update_field($r,$checkmail_body_field,$body);
}
echo "Updating Metadata \r\n";
# Move the file
$destination=get_resource_path($r,true,"",true,$file['extension']);
$result=rename($temp_dir."/".$file['filename'],$destination); echo "Moving file to filestore \r\n";
chmod($destination,0777);
# get file metadata
extract_exif_comment($r,$file['extension']); echo "Extracting Metadata... \r\n";
# Ensure folder is created, then create previews.
get_resource_path($r,false,"pre",true,$file['extension']);
if ($build_collection){
# Add Resource to Collection
echo "Adding Resource $r to Collection $collection \r\n";
add_resource_to_collection($r,$collection,true);
}
# Generate previews/thumbnails (if configured i.e if not completed by offline process 'create_previews.php')
global $enable_thumbnail_creation_on_upload;
if ($enable_thumbnail_creation_on_upload) {
create_previews($r,false,$file['extension']);
echo "Creating Previews... \r\n";
示例10: upload_file
//.........这里部分代码省略.........
}
if ($result == false) {
$status = "File upload error. Please check the size of the file you are trying to upload.";
return false;
} else {
global $camera_autorotation;
global $ffmpeg_audio_extensions;
if ($camera_autorotation) {
if ($autorotate && !in_array($extension, $ffmpeg_audio_extensions)) {
AutoRotateImage($filepath);
}
}
chmod($filepath, 0777);
global $icc_extraction;
global $ffmpeg_supported_extensions;
if ($icc_extraction && $extension != "pdf" && !in_array($extension, $ffmpeg_supported_extensions)) {
extract_icc_profile($ref, $extension);
}
$status = "Your file has been uploaded.";
}
}
}
# Store extension in the database and update file modified time.
if ($revert) {
$has_image = "";
} else {
$has_image = ",has_image=0";
}
sql_query("update resource set file_extension='{$extension}',preview_extension='jpg',file_modified=now() {$has_image} where ref='{$ref}'");
# delete existing resource_dimensions
sql_query("delete from resource_dimensions where resource='{$ref}'");
# get file metadata
if (!$no_exif) {
extract_exif_comment($ref, $extension);
} else {
global $merge_filename_with_title, $lang;
if ($merge_filename_with_title) {
$merge_filename_with_title_option = urlencode(getval('merge_filename_with_title_option', ''));
$merge_filename_with_title_include_extensions = urlencode(getval('merge_filename_with_title_include_extensions', ''));
$merge_filename_with_title_spacer = urlencode(getval('merge_filename_with_title_spacer', ''));
$original_filename = '';
if (isset($_REQUEST['name'])) {
$original_filename = $_REQUEST['name'];
} else {
$original_filename = $processfile['name'];
}
if ($merge_filename_with_title_include_extensions == 'yes') {
$merged_filename = $original_filename;
} else {
$merged_filename = strip_extension($original_filename);
}
// Get title field:
$resource = get_resource_data($ref);
$read_from = get_exiftool_fields($resource['resource_type']);
for ($i = 0; $i < count($read_from); $i++) {
if ($read_from[$i]['name'] == 'title') {
$oldval = get_data_by_field($ref, $read_from[$i]['ref']);
if (strpos($oldval, $merged_filename) !== FALSE) {
continue;
}
switch ($merge_filename_with_title_option) {
case $lang['merge_filename_title_do_not_use']:
// Do nothing since the user doesn't want to use this feature
break;
case $lang['merge_filename_title_replace']:
$newval = $merged_filename;
示例11: mb_basename
} // Test if thumbnail creation is allowed during upload
# Store original filename in field, if set
if (isset($filename_field))
{
$filename = $uploadfiles[$n];
if ($use_local)
{
$filename = mb_basename($filename);
}
update_field($ref,$filename_field, $filename);
}
# get file metadata
if (getval("no_exif","")=="") {extract_exif_comment($ref,$extension);}
# extract text from documents (e.g. PDF, DOC).
global $extracted_text_field;
if (isset($extracted_text_field) && !$no_exif) {extract_text($ref,$extension);}
$done++;
# Add to collection?
if ($collection!="")
{
$refs[] = $ref;
}
# Log this
daily_stat("Resource upload",$ref);
示例12: update_field
// Update metadata fields // HTML OPTIONS
update_field($r, $filename_field, $file['filename']);
update_field($r, $checkmail_subject_field, $subject);
if ($body_html != '' && $checkmail_html) {
update_field($r, $checkmail_body_field, $body_html);
} else {
update_field($r, $checkmail_body_field, $body);
}
echo "Updating Metadata \r\n";
# Move the file
$destination = get_resource_path($r, true, "", true, $file['extension']);
$result = rename($temp_dir . "/" . $file['filename'], $destination);
echo "Moving file to filestore \r\n";
chmod($destination, 0777);
# get file metadata
extract_exif_comment($r, $file['extension']);
echo "Extracting Metadata... \r\n";
# Ensure folder is created, then create previews.
get_resource_path($r, false, "pre", true, $file['extension']);
if ($build_collection) {
# Add Resource to Collection
echo "Adding Resource {$r} to Collection {$collection} \r\n";
add_resource_to_collection($r, $collection, true);
}
# Generate previews/thumbnails (if configured i.e if not completed by offline process 'create_previews.php')
global $enable_thumbnail_creation_on_upload;
if ($enable_thumbnail_creation_on_upload) {
create_previews($r, false, $file['extension']);
echo "Creating Previews... \r\n";
}
if (!$build_collection && $checkmail_confirm) {