本文整理汇总了PHP中iptcparse函数的典型用法代码示例。如果您正苦于以下问题:PHP iptcparse函数的具体用法?PHP iptcparse怎么用?PHP iptcparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iptcparse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: title_and_caption_not_utf8
function title_and_caption_not_utf8($meta, $file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
$meta = array();
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;
}
}
}
}
return $meta;
}
开发者ID:ratjadi,项目名称:andreaszeitler.net,代码行数:35,代码来源:functions.php
示例2: __construct
/**
* Class constructor
*
* @param int $image Image ID
* @param bool $onlyEXIF TRUE = will parse only EXIF data
* @return bool FALSE if the file does not exist or metadat could not be read
*/
public function __construct($image, $onlyEXIF = FALSE)
{
if (is_numeric($image)) {
$image = $this->get_registry()->get_utility('I_Image_Mapper')->find($image);
}
$this->image = apply_filters('ngg_find_image_meta', $image);
$this->file_path = $this->get_registry()->get_utility('I_Gallery_Storage')->get_image_abspath($this->image);
if (!@file_exists($this->file_path)) {
return FALSE;
}
$this->size = @getimagesize($this->file_path, $metadata);
if ($this->size && is_array($metadata)) {
// get exif - data
if (is_callable('exif_read_data')) {
$this->exif_data = @exif_read_data($this->file_path, 0, TRUE);
}
// stop here if we didn't need other meta data
if ($onlyEXIF) {
return TRUE;
}
// get the iptc data - should be in APP13
if (is_callable('iptcparse') && isset($metadata['APP13'])) {
$this->iptc_data = @iptcparse($metadata['APP13']);
}
// get the xmp data in a XML format
if (is_callable('xml_parser_create')) {
$this->xmp_data = $this->extract_XMP($this->file_path);
}
return TRUE;
}
return FALSE;
}
开发者ID:lcw07r,项目名称:productcampamsterdam.org,代码行数:39,代码来源:class.nextgen_metadata.php
示例3: PopulateExif
/**
* Get important EXIF information from the image
* @since Version 3.10.0
* @return array
* @param \Railpage\Gallery\Image $imageObject
*/
public static function PopulateExif($imageObject)
{
$imageSource = Album::ALBUMS_DIR . $imageObject->path;
/**
* Read the IPTC data
*/
#$size = getimagesize($imageSource, $info);
if (is_array($info)) {
$iptc = iptcparse($info["APP13"]);
if (isset($iptc['2#005'])) {
$imageObject->title = $iptc['2#005'][0];
}
}
/**
* Read the EXIF data
*/
$exif = exif_read_data($imageSource, 0, true);
if (isset($exif['IFD0']['ImageDescription'])) {
$imageObject->caption = $exif['IFD0']['ImageDescription'];
}
if (isset($exif['EXIF']['DateTimeOriginal'])) {
$imageObject->DateTaken = new DateTime($exif['EXIF']['DateTimeOriginal']);
}
if (isset($exif['GPS']['GPSLatitude']) && isset($exif['GPS']['GPSLongitude'])) {
$lat = self::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$lon = self::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
$imageObject->Place = Place::Factory($lat, $lon);
}
return $imageObject;
}
开发者ID:railpage,项目名称:railpagecore,代码行数:36,代码来源:ImageUtility.php
示例4: nggMeta
/**
* nggMeta::nggMeta()
*
* @param int $image path to a image
* @param bool $onlyEXIF parse only exif if needed
* @return
*/
function nggMeta($pic_id, $onlyEXIF = false)
{
//get the path and other data about the image
$this->image = nggdb::find_image($pic_id);
$this->image = apply_filters('ngg_find_image_meta', $this->image);
if (!file_exists($this->image->imagePath)) {
return false;
}
$this->size = @getimagesize($this->image->imagePath, $metadata);
if ($this->size && is_array($metadata)) {
// get exif - data
if (is_callable('exif_read_data')) {
$this->exif_data = @exif_read_data($this->image->imagePath, 0, true);
}
// stop here if we didn't need other meta data
if ($onlyEXIF) {
return true;
}
// get the iptc data - should be in APP13
if (is_callable('iptcparse') && isset($metadata['APP13'])) {
$this->iptc_data = @iptcparse($metadata['APP13']);
}
// get the xmp data in a XML format
if (is_callable('xml_parser_create')) {
$this->xmp_data = $this->extract_XMP($this->image->imagePath);
}
return true;
}
return false;
}
开发者ID:Ashleyotero,项目名称:oldest-old,代码行数:37,代码来源:meta.php
示例5: item_created
/**
* Handle the creation of a new photo.
* @todo Get tags from the XMP and/or IPTC data in the image
*
* @param Item_Model $photo
*/
static function item_created($photo)
{
$tags = array();
if ($photo->is_photo()) {
$path = $photo->file_path();
$size = getimagesize($photo->file_path(), $info);
if (is_array($info) && !empty($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
if (!empty($iptc["2#025"])) {
foreach ($iptc["2#025"] as $tag) {
$tag = str_replace("", "", $tag);
foreach (explode(",", $tag) as $word) {
$word = trim($word);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") {
$word = utf8_encode($word);
}
$tags[$word] = 1;
}
}
}
}
}
// @todo figure out how to read the keywords from xmp
foreach (array_keys($tags) as $tag) {
try {
tag::add($photo, $tag);
} catch (Exception $e) {
Kohana_Log::add("error", "Error adding tag: {$tag}\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
return;
}
开发者ID:andyst,项目名称:gallery3,代码行数:38,代码来源:tag_event.php
示例6: get_iptc_data
/**
* returns informations from IPTC metadata, mapping is done in this function.
*
* @param string $filename
* @param array $map
* @return array
*/
function get_iptc_data($filename, $map, $array_sep = ',')
{
global $conf;
$result = array();
$imginfo = array();
if (false == @getimagesize($filename, $imginfo)) {
return $result;
}
if (isset($imginfo['APP13'])) {
$iptc = iptcparse($imginfo['APP13']);
if (is_array($iptc)) {
$rmap = array_flip($map);
foreach (array_keys($rmap) as $iptc_key) {
if (isset($iptc[$iptc_key][0])) {
if ($iptc_key == '2#025') {
$value = implode($array_sep, array_map('clean_iptc_value', $iptc[$iptc_key]));
} else {
$value = clean_iptc_value($iptc[$iptc_key][0]);
}
foreach (array_keys($map, $iptc_key) as $pwg_key) {
$result[$pwg_key] = $value;
if (!$conf['allow_html_in_metadata']) {
// in case the origin of the photo is unsecure (user upload), we
// remove HTML tags to avoid XSS (malicious execution of
// javascript)
$result[$pwg_key] = strip_tags($result[$pwg_key]);
}
}
}
}
}
}
return $result;
}
开发者ID:squidjam,项目名称:Piwigo,代码行数:41,代码来源:functions_metadata.inc.php
示例7: iptcParser
/**
* Parse the iptc info and retrive the given value.
*
* Ref. http://codex.wordpress.org/Function_Reference/wp_read_image_metadata#Parameters
* WP already adds some IPTC data
*
* @param $value The item you want returned
* @param $image The image you want info from
*/
public function iptcParser($value = null, $image = null)
{
$size = getimagesize($image, $info);
if (!isset($info['APP13'])) {
return;
}
$iptc = iptcparse($info['APP13']);
switch ($value) {
case 'keywords':
if (isset($iptc['2#025'])) {
return $iptc['2#025'];
}
case 'city':
if (isset($iptc['2#090'][0])) {
return $iptc['2#090'][0];
}
case 'region':
if (isset($iptc['2#095'][0])) {
return $iptc['2#095'][0];
}
case 'country':
if (isset($iptc['2#101'][0])) {
return $iptc['2#101'][0];
}
default:
return false;
}
}
开发者ID:waifei,项目名称:zm-upload,代码行数:37,代码来源:ImageMeta.php
示例8: __construct
/**
* Parses the nggMeta data only if needed
* @param int $image path to a image
* @param bool $onlyEXIF parse only exif if needed
* @return
*/
function __construct($image_or_id, $onlyEXIF = false)
{
if (is_int($image_or_id)) {
//get the path and other data about the image
$this->image = C_Image_Mapper::get_instance()->find($image_or_id);
} else {
$this->image = $image_or_id;
}
$imagePath = C_Gallery_Storage::get_instance()->get_image_abspath($this->image);
if (!file_exists($imagePath)) {
return false;
}
$this->size = @getimagesize($imagePath, $metadata);
if ($this->size && is_array($metadata)) {
// get exif - data
if (is_callable('exif_read_data')) {
$this->exif_data = @exif_read_data($imagePath, NULL, TRUE);
}
// stop here if we didn't need other meta data
if ($onlyEXIF) {
return true;
}
// get the iptc data - should be in APP13
if (is_callable('iptcparse') && isset($metadata['APP13'])) {
$this->iptc_data = @iptcparse($metadata['APP13']);
}
// get the xmp data in a XML format
if (is_callable('xml_parser_create')) {
$this->xmp_data = $this->extract_XMP($imagePath);
}
return true;
}
return false;
}
开发者ID:albinmartinsson91,项目名称:ux_blog,代码行数:40,代码来源:meta.php
示例9: parseImage
public static function parseImage($filename)
{
if (@getimagesize($filename, $data) && isset($data['APP13'])) {
return self::translateKeys(iptcparse($data['APP13']));
}
return null;
}
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:7,代码来源:IptcUtils.php
示例10: nggMeta
/**
* nggMeta::nggMeta()
*
* @param string $image path to a image
* @param bool $onlyEXIF parse only exif if needed
* @return
*/
function nggMeta($image, $onlyEXIF = false)
{
$this->imagePath = $image;
if (!file_exists($this->imagePath)) {
return false;
}
$size = @getimagesize($this->imagePath, $metadata);
if ($size && is_array($metadata)) {
// get exif - data
if (is_callable('exif_read_data')) {
$this->exif_data = @exif_read_data($this->imagePath, 0, true);
}
// stop here if we didn't need other meta data
if ($onlyEXIF) {
return true;
}
// get the iptc data - should be in APP13
if (is_callable('iptcparse')) {
$this->iptc_data = @iptcparse($metadata["APP13"]);
}
// get the xmp data in a XML format
if (is_callable('xml_parser_create')) {
$this->xmp_data = $this->extract_XMP($this->imagePath);
}
return true;
}
return false;
}
开发者ID:pravinhirmukhe,项目名称:flow1,代码行数:35,代码来源:meta.php
示例11: item_created
/**
* Handle the creation of a new photo.
* @todo Get tags from the XMP and/or IPTC data in the image
*
* @param Item_Model $photo
*/
static function item_created($photo)
{
$tags = array();
if ($photo->is_photo()) {
$path = $photo->file_path();
$size = getimagesize($photo->file_path(), $info);
if (is_array($info) && !empty($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
if (!empty($iptc["2#025"])) {
foreach ($iptc["2#025"] as $tag) {
$tag = str_replace("", "", $tag);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($tag) != "UTF-8") {
$tag = utf8_encode($tag);
}
$tags[$tag] = 1;
}
}
}
}
// @todo figure out how to read the keywords from xmp
foreach (array_keys($tags) as $tag) {
tag::add($photo, $tag);
}
return;
}
开发者ID:xafr,项目名称:gallery3,代码行数:31,代码来源:tag_event.php
示例12: parseIPTC
public function parseIPTC()
{
$aArr = @exif_read_data($this->sFilename, 'IDF0', true);
$size = getimagesize($this->sFilename, $info);
if (!isset($info['APP13'])) {
return false;
}
$iptc = iptcparse($info['APP13']);
if (isset($iptc["2#120"][0])) {
# caption
$this->aAttributes['title'] = trim($iptc["2#120"][0]);
} else {
if (isset($iptc["2#105"][0])) {
# headline
$this->aAttributes['title'] = trim($iptc["2#105"][0]);
} else {
if (isset($iptc["2#005"][0])) {
# graphic name
$this->aAttributes['title'] = trim($iptc["2#005"][0]);
}
}
}
if (isset($iptc["2#055"][0]) && isset($iptc["2#060"][0])) {
# creation date
$iTimestamp = self::timestampFromIPTC($iptc["2#055"][0], $iptc["2#060"][0]);
if ($iTimestamp !== false) {
$this->aAttributes['datetime'] = $iTimestamp;
}
}
return true;
}
开发者ID:cnlpete,项目名称:image-metadata-parser,代码行数:31,代码来源:imageMetadataParser.php
示例13: iptc
public function iptc($filename)
{
$size = getimagesize($filename, $info);
if (isset($info["APP13"])) {
$this->_metadata = iptcparse($info["APP13"]);
}
$this->_file = $filename;
}
开发者ID:BGCX261,项目名称:zieli-svn-to-git,代码行数:8,代码来源:Iptc.php
示例14: checkIptc
private function checkIptc()
{
getimagesize($this->_filename, $info);
if (isset($info['APP13'])) {
$this->_meta = iptcparse($info['APP13']);
return true;
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:tags.php
示例15: __construct
public function __construct($file)
{
if (!(file_exists($file) && is_readable($file))) {
throw new FileReadException(sprintf('file %s in not readable', $file));
}
getimagesize($file, $this->iptc);
$this->iptc_app13 = @iptcparse($this->iptc['APP13']);
}
开发者ID:rodgermd,项目名称:mura-show.com,代码行数:8,代码来源:IptcDataParser.php
示例16: read
/**
* Creates a segment instance
*
* @param string $marker
* @param string $bytes
* @return self
*/
public static function read($marker, $bytes)
{
if (is_array($iptc = iptcparse($bytes))) {
return XPClass::forName('img.io.IptcSegment')->newInstance($marker, $iptc);
} else {
return new self($marker, $bytes);
}
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:APP13Segment.class.php
示例17: __construct
function __construct($filename)
{
$info = null;
$size = getimagesize($filename, $info);
if (isset($info["APP13"])) {
$this->meta = iptcparse($info["APP13"]);
}
$this->file = $filename;
}
开发者ID:WrinklyNinja,项目名称:emelhamlet.co.uk,代码行数:9,代码来源:IPTC.php
示例18: iptc
function iptc($filename)
{
$size = getimagesize($filename, $info);
$this->hasmeta = isset($info["APP13"]);
if ($this->hasmeta) {
$this->meta = iptcparse($info["APP13"]);
}
$this->file = $filename;
}
开发者ID:afrog33k,项目名称:sdk.ralcr,代码行数:9,代码来源:iptc.php
示例19: extract
static function extract($item)
{
$keys = array();
// Only try to extract EXIF from photos
if ($item->is_photo() && $item->mime_type == "image/jpeg") {
$data = array();
require_once MODPATH . "exif/lib/exif.php";
$exif_raw = read_exif_data_raw($item->file_path(), false);
if (isset($exif_raw['ValidEXIFData'])) {
foreach (self::_keys() as $field => $exifvar) {
if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) {
$value = $exif_raw[$exifvar[0]][$exifvar[1]];
if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") {
$value = utf8_encode($value);
}
$keys[$field] = Input::clean($value);
if ($field == "DateTime") {
$time = strtotime($value);
if ($time > 0) {
$item->captured = $time;
}
} else {
if ($field == "Caption" && !$item->description) {
$item->description = $value;
}
}
}
}
}
$size = getimagesize($item->file_path(), $info);
if (is_array($info) && !empty($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
foreach (array("Keywords" => "2#025", "Caption" => "2#120") as $keyword => $iptc_key) {
if (!empty($iptc[$iptc_key])) {
$value = implode(" ", $iptc[$iptc_key]);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") {
$value = utf8_encode($value);
}
$keys[$keyword] = Input::clean($value);
if ($keyword == "Caption" && !$item->description) {
$item->description = $value;
}
}
}
}
}
$item->save();
$record = ORM::factory("exif_record")->where("item_id", "=", $item->id)->find();
if (!$record->loaded()) {
$record->item_id = $item->id;
}
$record->data = serialize($keys);
$record->key_count = count($keys);
$record->dirty = 0;
$record->save();
}
开发者ID:andyst,项目名称:gallery3,代码行数:56,代码来源:exif.php
示例20: Image_IPTC
/**
* Constructor
*
* @param string
* The name of the image file to access and extract IPTC information from.
*
* @access public
*/
function Image_IPTC($sFilename)
{
$this->_sFilename = $sFilename;
if (is_file($this->_sFilename)) {
if (@getimagesize($this->_sFilename, $aAPP) && !empty($aAPP)) {
$this->_aIPTC = @iptcparse($aAPP['APP13']);
$this->_bIPTCParse = true;
}
}
}
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:18,代码来源:IPTC.php
注:本文中的iptcparse函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论