本文整理汇总了PHP中wp_exif_date2ts函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_exif_date2ts函数的具体用法?PHP wp_exif_date2ts怎么用?PHP wp_exif_date2ts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_exif_date2ts函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_read_image_metadata
//.........这里部分代码省略.........
// that are likely to be useful. Fractions and numbers are converted to
// floats, dates to unix timestamps, and everything else to strings.
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
// read iptc first, since it might contain data not available in exif such
// as caption, description etc
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
// headline, "A brief synopsis of the caption."
if (!empty($iptc['2#105'][0])) {
$meta['title'] = trim($iptc['2#105'][0]);
} elseif (!empty($iptc['2#005'][0])) {
$meta['title'] = trim($iptc['2#005'][0]);
}
if (!empty($iptc['2#120'][0])) {
// description / legacy caption
$caption = trim($iptc['2#120'][0]);
if (empty($meta['title'])) {
// Assume the title is stored in 2:120 if it's short.
if (strlen($caption) < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
if (!empty($iptc['2#110'][0])) {
// credit
$meta['credit'] = trim($iptc['2#110'][0]);
} elseif (!empty($iptc['2#080'][0])) {
// creator / legacy byline
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = trim($iptc['2#116'][0]);
}
}
}
// fetch additional info from exif if available
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['Title'])) {
$meta['title'] = trim($exif['Title']);
}
if (!empty($exif['ImageDescription'])) {
if (empty($meta['title']) && strlen($exif['ImageDescription']) < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($exif['ImageDescription']);
if (!empty($exif['COMPUTED']['UserComment']) && trim($exif['COMPUTED']['UserComment']) != $meta['title']) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
} elseif (trim($exif['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (!empty($exif['Comments']) && trim($exif['Comments']) != $meta['title']) {
$meta['caption'] = trim($exif['Comments']);
}
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
if (!empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (!empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']);
}
}
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
}
}
return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType);
}
示例2: bwg_wp_read_image_metadata
private function bwg_wp_read_image_metadata($file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '', 'orientation' => 0);
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (!empty($iptc['2#105'][0])) {
$meta['title'] = trim($iptc['2#105'][0]);
} elseif (!empty($iptc['2#005'][0])) {
$meta['title'] = trim($iptc['2#005'][0]);
}
if (!empty($iptc['2#120'][0])) {
$caption = trim($iptc['2#120'][0]);
if (empty($meta['title'])) {
mbstring_binary_safe_encoding();
$caption_length = strlen($caption);
reset_mbstring_encoding();
if ($caption_length < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
if (!empty($iptc['2#110'][0])) {
$meta['credit'] = trim($iptc['2#110'][0]);
} elseif (!empty($iptc['2#080'][0])) {
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
$meta['copyright'] = trim($iptc['2#116'][0]);
}
}
}
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (empty($meta['title']) && !empty($exif['Title'])) {
$meta['title'] = trim($exif['Title']);
}
if (!empty($exif['ImageDescription'])) {
mbstring_binary_safe_encoding();
$description_length = strlen($exif['ImageDescription']);
reset_mbstring_encoding();
if (empty($meta['title']) && $description_length < 80) {
$meta['title'] = trim($exif['ImageDescription']);
if (empty($meta['caption']) && !empty($exif['COMPUTED']['UserComment']) && trim($exif['COMPUTED']['UserComment']) != $meta['title']) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
} elseif (empty($meta['caption']) && trim($exif['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (empty($meta['caption']) && !empty($exif['Comments']) && trim($exif['Comments']) != $meta['title']) {
$meta['caption'] = trim($exif['Comments']);
}
if (empty($meta['credit'])) {
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
}
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']);
}
if (!empty($exif['Orientation'])) {
$meta['orientation'] = $exif['Orientation'];
}
}
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
//.........这里部分代码省略.........
示例3: wp_read_image_metadata
//.........这里部分代码省略.........
// creator / legacy byline
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) && !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = trim($iptc['2#116'][0]);
}
if (!empty($iptc['2#025'][0])) {
// keywords array
$meta['keywords'] = array_values($iptc['2#025']);
}
}
}
/**
* Filter the image types to check for exif data.
*
* @since 2.5.0
*
* @param array $image_types Image types to check for exif data.
*/
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['ImageDescription'])) {
mbstring_binary_safe_encoding();
$description_length = strlen($exif['ImageDescription']);
reset_mbstring_encoding();
if (empty($meta['title']) && $description_length < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($exif['ImageDescription']);
}
if (empty($meta['caption']) && !empty($exif['COMPUTED']['UserComment'])) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
if (empty($meta['caption'])) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (empty($meta['caption']) && !empty($exif['Comments'])) {
$meta['caption'] = trim($exif['Comments']);
}
if (empty($meta['credit'])) {
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
}
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']);
}
if (!empty($exif['Orientation'])) {
$meta['orientation'] = $exif['Orientation'];
}
}
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
}
}
foreach ($meta['keywords'] as $key => $keyword) {
if (!seems_utf8($keyword)) {
$meta['keywords'][$key] = utf8_encode($keyword);
}
}
$meta = wp_kses_post_deep($meta);
/**
* Filter the array of meta data read from an image's exif data.
*
* @since 2.5.0
* @since 4.4.0 The `$iptc` parameter was added.
*
* @param array $meta Image meta data.
* @param string $file Path to image file.
* @param int $sourceImageType Type of image.
* @param array $iptc IPTC data.
*/
return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc);
}
示例4: wp_read_image_metadata
/**
* Get extended image metadata, exif or iptc as available.
*
* Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
* created_timestamp, focal_length, shutter_speed, and title.
*
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
* and time, caption, copyright, and title. Also includes FNumber, Model,
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
*
* @todo Try other exif libraries if available.
* @since 2.5.0
*
* @param string $file
* @return bool|array False on failure. Image metadata array on success.
*/
function wp_read_image_metadata($file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
// exif contains a bunch of data we'll probably never need formatted in ways
// that are difficult to use. We'll normalize it and just extract the fields
// that are likely to be useful. Fractions and numbers are converted to
// floats, dates to unix timestamps, and everything else to strings.
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
// read iptc first, since it might contain data not available in exif such
// as caption, description etc
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (!empty($iptc['2#110'][0])) {
// credit
$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
} elseif (!empty($iptc['2#080'][0])) {
// byline
$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#120'][0])) {
// caption
$meta['caption'] = utf8_encode(trim($iptc['2#120'][0]));
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = utf8_encode(trim($iptc['2#116'][0]));
}
if (!empty($iptc['2#005'][0])) {
// title
$meta['title'] = utf8_encode(trim($iptc['2#005'][0]));
}
}
}
// fetch additional info from exif if available
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (!empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = $exif['ISOSpeedRatings'];
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = wp_exif_frac2dec($exif['ExposureTime']);
}
}
return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType);
}
示例5: extract_metadata
function extract_metadata($remote_meta)
{
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
$meta['title'] = $this->extract_meta_value($remote_meta, array('Headline', 'ObjectName'));
$caption = $this->extract_meta_value($remote_meta, array('Caption-Abstract'));
if (!empty($caption)) {
if (empty($meta['title'])) {
if (strlen($caption) < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
$meta['credit'] = $this->extract_meta_value($remote_meta, array('Artist', 'Author', 'Credit', 'By-line'));
if (!empty($remote_meta["DateCreated"]) and !empty($remote_meta["TimeCreated"])) {
// created date and time
$meta['created_timestamp'] = strtotime($remote_meta["DateCreated"] . ' ' . $remote_meta["TimeCreated"]);
}
$meta['copyright'] = $this->extract_meta_value($remote_meta, array('Copyright', 'CopyrightNotice'));
if (!empty($remote_meta['Title'])) {
$meta['title'] = trim($remote_meta['Title']);
}
if (!empty($remote_meta['ImageDescription'])) {
if (empty($meta['title']) && strlen($remote_meta['ImageDescription']) < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($remote_meta['ImageDescription']);
if (!empty($remote_meta['UserComment']) && trim($remote_meta['UserComment']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['UserComment']);
}
} elseif (trim($remote_meta['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['ImageDescription']);
}
} elseif (!empty($remote_meta['Comments']) && trim($remote_meta['Comments']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['Comments']);
}
$meta['camera'] = $this->extract_meta_value($remote_meta, array('Model'));
if (!empty($remote_meta['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($remote_meta['DateTimeDigitized']);
}
$meta['iso'] = $this->extract_meta_value($remote_meta, array('ISO'), 0);
if (!empty($remote_meta['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($remote_meta['FNumber']), 2);
}
if (!empty($remote_meta['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($remote_meta['FocalLength']);
}
if (!empty($remote_meta['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($remote_meta['ExposureTime']);
}
return $meta;
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
}
}
}
示例6: wp_read_image_metadata
//.........这里部分代码省略.........
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
// Camera Make
if (!empty($exif['Make'])) {
$meta['make'] = $exif['Make'];
}
// Camera Model
if (!empty($exif['Model'])) {
$meta['model'] = trim($exif['Model']);
}
// Exposure Time (shutter speed)
if (!empty($exif['ExposureTime'])) {
$meta['exposure'] = $exif['ExposureTime'] . 's';
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']) . 's';
}
// Aperture
if (!empty($exif['COMPUTED']['ApertureFNumber'])) {
$meta['aperture'] = $exif['COMPUTED']['ApertureFNumber'];
} elseif (!empty($exif['FNumber'])) {
$meta['aperture'] = 'f/' . (string) round(wp_exif_frac2dec($exif['FNumber']), 2);
}
// ISO
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
// Date
if (!empty($exif['DateTime'])) {
$meta['date'] = $exif['DateTime'];
}
// Created TimeStamp
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
// Lens
if (!empty($exif['UndefinedTag:0xA434'])) {
$meta['lens'] = $exif['UndefinedTag:0xA434'];
}
// Focus Distance
if (!empty($exif['COMPUTED']['FocusDistance'])) {
$meta['distance'] = $exif['COMPUTED']['FocusDistance'];
}
// Focal Length
if (!empty($exif['FocalLength'])) {
$meta['focallength'] = (string) round(wp_exif_frac2dec($exif['FocalLength'])) . 'mm';
}
// Focal Length 35mm
if (!empty($exif['FocalLengthIn35mmFilm'])) {
$meta['focallength35'] = $exif['FocalLengthIn35mmFilm'] . 'mm';
}
// Flash data
if (!empty($exif['Flash'])) {
// we need to interpret the result - it's given as a number and we want a human-readable description.
$fdata = $exif['Flash'];
switch ($fdata) {
case 0:
$fdata = 'No Flash';
break;
case 1:
$fdata = 'Flash';
break;
case 5:
$fdata = 'Flash, strobe return light not detected';
break;
case 7: