本文整理汇总了PHP中exif_read_data函数的典型用法代码示例。如果您正苦于以下问题:PHP exif_read_data函数的具体用法?PHP exif_read_data怎么用?PHP exif_read_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exif_read_data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getexif
function getexif($img)
{
$imgtype = array("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF(intel byte order)", "TIFF(motorola byte order)", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM");
$Orientation = array("", "top left side", "top right side", "bottom right side", "bottom left side", "left side top", "right side top", "right side bottom", "left side bottom");
$ResolutionUnit = exif_lang('resolutionunit');
$YCbCrPositioning = array("", "the center of pixel array", "the datum point");
$ExposureProgram = exif_lang('exposureprogram');
$MeteringMode_arr = exif_lang('meteringmode');
$Lightsource_arr = exif_lang('lightsource');
$Flash_arr = array("0" => "flash did not fire", "1" => "flash fired", "5" => "flash fired but strobe return light not detected", "7" => "flash fired and strobe return light detected");
if (!function_exists('exif_read_data')) {
return exif_lang('img_info');
}
$exif = @exif_read_data($img, "IFD0");
if ($exif === false) {
$new_img_info = exif_lang('img_info');
} else {
@($exif = exif_read_data($img, 0, true));
foreach ($exif as $type => $typearr) {
foreach ($typearr as $key => $kval) {
if (is_array($kval)) {
foreach ($kval as $vkey => $value) {
$str = dhtmlspecialchars(preg_replace("/[^\\[A-Za-z0-9_\\.\\/:\\s-\\]]/", '', trim($value)));
$exif[$type][$key][$vkey] = $str;
}
} elseif (!in_array($key, array('ComponentsConfiguration', 'FileSource', 'SceneType'))) {
$str = dhtmlspecialchars(preg_replace("/[^\\[A-Za-z0-9_\\.\\/:\\s-\\]]/", '', trim($kval)));
$exif[$type][$key] = $str;
}
}
}
$new_img_info = array(exif_lang('FileName') => $exif[FILE][FileName], exif_lang('FileType') => $imgtype[$exif[FILE][FileType]], exif_lang('MimeType') => $exif[FILE][MimeType], exif_lang('FileSize') => $exif[FILE][FileSize], exif_lang('FileDateTime') => date("Y-m-d H:i:s", $exif[FILE][FileDateTime]), exif_lang('ImageDescription') => $exif[IFD0][ImageDescription], exif_lang('Make') => $exif[IFD0][Make], exif_lang('Model') => $exif[IFD0][Model], exif_lang('Orientation') => $Orientation[$exif[IFD0][Orientation]], exif_lang('XResolution') => $exif[IFD0][XResolution] . $ResolutionUnit[$exif[IFD0][ResolutionUnit]], exif_lang('YResolution') => $exif[IFD0][YResolution] . $ResolutionUnit[$exif[IFD0][ResolutionUnit]], exif_lang('Software') => $exif[IFD0][Software], exif_lang('DateTime') => $exif[IFD0][DateTime], exif_lang('Artist') => $exif[IFD0][Artist], exif_lang('YCbCrPositioning') => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]], exif_lang('Copyright') => $exif[IFD0][Copyright], exif_lang('Photographer') => $exif[COMPUTED][Copyright . Photographer], exif_lang('Editor') => $exif[COMPUTED][Copyright . Editor], exif_lang('ExifVersion') => $exif[EXIF][ExifVersion], exif_lang('FlashPixVersion') => "Ver. " . number_format($exif[EXIF][FlashPixVersion] / 100, 2), exif_lang('DateTimeOriginal') => $exif[EXIF][DateTimeOriginal], exif_lang('DateTimeDigitized') => $exif[EXIF][DateTimeDigitized], exif_lang('Height') => $exif[COMPUTED][Height], exif_lang('Width') => $exif[COMPUTED][Width], exif_lang('ApertureValue') => $exif[EXIF][ApertureValue], exif_lang('ShutterSpeedValue') => $exif[EXIF][ShutterSpeedValue], exif_lang('ApertureFNumber') => $exif[COMPUTED][ApertureFNumber], exif_lang('MaxApertureValue') => "F" . $exif[EXIF][MaxApertureValue], exif_lang('ExposureTime') => $exif[EXIF][ExposureTime], exif_lang('FNumber') => $exif[EXIF][FNumber], exif_lang('MeteringMode') => getimageinfoval($exif[EXIF][MeteringMode], $MeteringMode_arr), exif_lang('LightSource') => getimageinfoval($exif[EXIF][LightSource], $Lightsource_arr), exif_lang('Flash') => getimageinfoval($exif[EXIF][Flash], $Flash_arr), exif_lang('ExposureMode') => $exif[EXIF][ExposureMode] == 1 ? exif_lang('manual') : exif_lang('auto'), exif_lang('WhiteBalance') => $exif[EXIF][WhiteBalance] == 1 ? exif_lang('manual') : exif_lang('auto'), exif_lang('ExposureProgram') => $ExposureProgram[$exif[EXIF][ExposureProgram]], exif_lang('ExposureBiasValue') => $exif[EXIF][ExposureBiasValue] . "EV", exif_lang('ISOSpeedRatings') => $exif[EXIF][ISOSpeedRatings], exif_lang('ComponentsConfiguration') => bin2hex($exif[EXIF][ComponentsConfiguration]) == "01020300" ? "YCbCr" : "RGB", exif_lang('CompressedBitsPerPixel') => $exif[EXIF][CompressedBitsPerPixel] . "Bits/Pixel", exif_lang('FocusDistance') => $exif[COMPUTED][FocusDistance] . "m", exif_lang('FocalLength') => $exif[EXIF][FocalLength] . "mm", exif_lang('FocalLengthIn35mmFilm') => $exif[EXIF][FocalLengthIn35mmFilm] . "mm", exif_lang('UserCommentEncoding') => $exif[COMPUTED][UserCommentEncoding], exif_lang('UserComment') => $exif[COMPUTED][UserComment], exif_lang('ColorSpace') => $exif[EXIF][ColorSpace] == 1 ? "sRGB" : "Uncalibrated", exif_lang('ExifImageLength') => $exif[EXIF][ExifImageLength], exif_lang('ExifImageWidth') => $exif[EXIF][ExifImageWidth], exif_lang('FileSource') => bin2hex($exif[EXIF][FileSource]) == 0x3 ? "digital still camera" : "unknown", exif_lang('SceneType') => bin2hex($exif[EXIF][SceneType]) == 0x1 ? "A directly photographed image" : "unknown", exif_lang('ThumbFileType') => $exif[COMPUTED][Thumbnail . FileType], exif_lang('ThumbMimeType') => $exif[COMPUTED][Thumbnail . MimeType]);
}
return $new_img_info;
}
开发者ID:softhui,项目名称:discuz,代码行数:35,代码来源:function_exif.php
示例2: get_exif
function get_exif($file)
{
if (!function_exists('exif_read_data')) {
return false;
}
$exif = @exif_read_data($file, "IFD0");
if ($exif === false) {
return false;
}
$exif_info = exif_read_data($file, NULL, true);
$exif_arr = $this->supported_exif();
$new_exif = array();
foreach ($exif_arr as $k => $v) {
$arr = explode('.', $v);
if (isset($exif_info[$arr[0]])) {
if (isset($exif_info[$arr[0]][$arr[1]])) {
$new_exif[$k] = $exif_info[$arr[0]][$arr[1]];
} else {
$new_exif[$k] = false;
}
} else {
$new_exif[$k] = false;
}
if ($k == 'Software' && !empty($new_exif['Software'])) {
$new_exif['Software'] = preg_replace('/([^a-zA-Z0-9_\\-,\\.\\:&#@!\\(\\)\\s]+)/i', '', $new_exif['Software']);
}
}
return $new_exif;
}
开发者ID:vluo,项目名称:myPoto,代码行数:29,代码来源:exif.class.php
示例3: readJPGExifData
/**
* This function extracts the EXIF data from a JPG image and convert then convert the GPS coordinates in degree
*
* @param $img
* @param $directory
*
*/
function readJPGExifData($img, $directory)
{
$imgDir = $directory . $img;
//reading exif data
$exif = exif_read_data($imgDir, 0, true);
//preparing the GPS coordinates
$gpsLat = $exif["GPS"]["GPSLatitude"];
$degLat = $gpsLat[0];
$minLat = $gpsLat[1];
$secLat = $gpsLat[2];
$gpsLng = $exif["GPS"]["GPSLongitude"];
$degLon = $gpsLng[0];
$minLon = $gpsLng[1];
$secLon = $gpsLng[2];
//converting GPS lat data to degree
$secLat = $secLat[0] . $secLat[1] . "," . $secLat[2] . $secLat[3] . $secLat[4];
$minLat2 = $minLat / 60;
$secLat2 = $secLat * (1 / 3600);
$lat = $degLat + $minLat2 + $secLat2;
//Lat coordinate - degree
//converting GPS long data to degree
$secLon = $secLon[0] . $secLon[1] . "," . $secLon[2] . $secLon[3] . $secLon[4];
$minLon2 = $minLon / 60;
$secLon2 = $secLon * (1 / 3600);
$lng = $degLon + $minLon2 + $secLon2;
//Long coordinate - degree
//creating Drupal content with the image lat, lng data
createContentFromImage($lat, $lng, $img);
//removing the image to prevent any kind of confusion next time
@unlink($_SERVER["DOCUMENT_ROOT"] . $imgDir);
}
开发者ID:marshall86,项目名称:Drupal-content-generator,代码行数:38,代码来源:main.php
示例4: getImage
private function getImage()
{
$image = imagecreatefromstring(file_get_contents($this->file['tmp_name']));
if ($this->currentExtension == 'jpg' || $this->currentExtension == 'jpeg') {
$exif = exif_read_data($this->file['tmp_name']);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$image = imagerotate($image, 90, 0);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
}
}
}
// Get new sizes
$width = imagesx($image);
$height = imagesy($image);
//list($width, $height) = getimagesize($this->file['tmp_name']);
list($newWidth, $newHeight) = $this->getScaledDimArray($image, 800);
// Load
$resizeImage = imagecreatetruecolor($newWidth, $newHeight);
// Resize
imagecopyresized($resizeImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
return $resizeImage;
}
开发者ID:ambujaacool,项目名称:MyApp,代码行数:30,代码来源:ImageUpload.php
示例5: __construct
/**
* Create Exif class
*
* @param string $file
* @author Thibaud Rohmer
*/
public function __construct($file = null)
{
/// No file given
if (!isset($file)) {
return;
}
/// File isn't an image
if (is_array($file) || !File::Type($file) || File::Type($file) != "Image") {
return;
}
/// No right to view
if (!Judge::view($file)) {
return;
}
/// No exif extension installed
if (!in_array("exif", get_loaded_extensions())) {
$infos[''] = "Exif extension is not installed on the server";
return;
}
/// Create wanted table
$this->init_wanted();
/// Read exif
$raw_exif = @exif_read_data($file);
/// Parse exif
foreach ($this->wanted as $name => $data) {
foreach ($data as $d) {
if (isset($raw_exif[$d])) {
$this->exif[$name] = $this->parse_exif($d, $raw_exif);
}
}
}
$this->filename = basename($file);
}
开发者ID:achappuis,项目名称:PhotoShow,代码行数:39,代码来源:Exif.php
示例6: get_orientation_degrees
/**
* Get image orientation from exif
*/
public static function get_orientation_degrees($filename)
{
if (in_array("exif", get_loaded_extensions())) {
$raw_exif = @exif_read_data($filename);
switch ($raw_exif['Orientation']) {
case 1:
case 2:
$degrees = 0;
break;
case 3:
case 4:
$degrees = 180;
break;
case 5:
case 6:
$degrees = -90;
break;
case 7:
case 8:
$degrees = 90;
break;
default:
$degrees = 0;
}
} else {
$degrees = 0;
}
return $degrees;
}
开发者ID:remyhonig,项目名称:PhotoShow,代码行数:32,代码来源:Provider.php
示例7: set
public function set($k, $v)
{
switch ($k) {
case 'file':
$ret = parent::set($k, $v);
// Clear out the cache
$this->_file = null;
// File was updated... load the exif data too!
// Note, only do this if it was an image!
$file = $this->getOriginalFile();
if ($file->isImage() && $file->getExtension() == 'jpg') {
$this->_data['exifdata'] = json_encode(exif_read_data($file->getFilename()));
} else {
$this->_data['exifdata'] = null;
}
// Also if the file is new and it didn't exist... set the uploader id.
if (!$this->_exists) {
$this->_data['uploaderid'] = \Core\user()->get('id');
}
return $ret;
case 'exifdata':
// exif data cannot be changed externally!
return false;
default:
return parent::set($k, $v);
}
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:27,代码来源:GalleryImageModel.php
示例8: __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
示例9: getid3_jpg
function getid3_jpg(&$fd, &$ThisFileInfo)
{
$ThisFileInfo['fileformat'] = 'jpg';
$ThisFileInfo['video']['dataformat'] = 'jpg';
$ThisFileInfo['video']['lossless'] = false;
$ThisFileInfo['video']['bits_per_sample'] = 24;
$ThisFileInfo['video']['pixel_aspect_ratio'] = (double) 1;
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
list($width, $height, $type) = getid3_lib::GetDataImageSize(fread($fd, $ThisFileInfo['filesize']));
if ($type == 2) {
$ThisFileInfo['video']['resolution_x'] = $width;
$ThisFileInfo['video']['resolution_y'] = $height;
if (version_compare(phpversion(), '4.2.0', '>=')) {
if (function_exists('exif_read_data')) {
ob_start();
$ThisFileInfo['jpg']['exif'] = exif_read_data($ThisFileInfo['filenamepath'], '', true, false);
$errors = ob_get_contents();
if ($errors) {
$ThisFileInfo['error'][] = strip_tags($errors);
unset($ThisFileInfo['jpg']['exif']);
}
ob_end_clean();
} else {
$ThisFileInfo['warning'][] = 'EXIF parsing only available when ' . (GETID3_OS_ISWINDOWS ? 'php_exif.dll enabled' : 'compiled with --enable-exif');
}
} else {
$ThisFileInfo['warning'][] = 'EXIF parsing only available in PHP v4.2.0 and higher compiled with --enable-exif (or php_exif.dll enabled for Windows). You are using PHP v' . phpversion();
}
return true;
}
unset($ThisFileInfo['fileformat']);
return false;
}
开发者ID:ookwudili,项目名称:chisimba,代码行数:33,代码来源:module.graphic.jpg.php
示例10: display_image
public function display_image(Page $page, Image $image)
{
global $config;
$u_ilink = $image->get_image_link();
if ($config->get_bool("image_show_meta") && function_exists("exif_read_data")) {
# FIXME: only read from jpegs?
$exif = @exif_read_data($image->get_image_filename(), 0, true);
if ($exif) {
$head = "";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
if ($key == "IFD0") {
// Cheap fix for array'd values in EXIF-data
if (is_array($val)) {
$val = implode(',', $val);
}
$head .= html_escape("{$name}: {$val}") . "<br>\n";
}
}
}
if ($head) {
$page->add_block(new Block("EXIF Info", $head, "left"));
}
}
}
$html = "<img alt='main image' class='shm-main-image' id='main_image' src='{$u_ilink}' " . "data-width='{$image->width}' data-height='{$image->height}'>";
$page->add_block(new Block("Image", $html, "main", 10));
}
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:28,代码来源:theme.php
示例11: save
function save($filename, $image_type = 2, $compression = 80, $permissions = null)
{
if ($image_type == 2) {
//jpg
$exif = exif_read_data($filename);
$ort = 1;
if (isset($exif['Orientation'])) {
$ort = $exif['Orientation'];
}
if ($ort == 3) {
$this->image = imagerotate($this->image, 180, -1);
} else {
if ($ort == 5 || $ort == 6 || $ort == 7) {
$this->image = imagerotate($this->image, -90, -1);
} else {
if ($ort == 8) {
$this->image = imagerotate($this->image, 90, -1);
}
}
}
imagejpeg($this->image, $filename);
//imagejpeg($this->image,$filename,$compression);
} elseif ($image_type == 1) {
//gif
imagegif($this->image, $filename);
} elseif ($image_type == 3) {
//png
imagepng($this->image, $filename);
}
if ($permissions != null) {
chmod($filename, $permissions);
}
}
开发者ID:Tripbull,项目名称:newrepo,代码行数:33,代码来源:class.resizephoto.php
示例12: add
public function add($fileName, $description = null, $date = null)
{
// create item
$item["file"] = $fileName;
$item["description"] = $description;
if (!$date) {
$exif_data = @exif_read_data($this->dir . "/" . $fileName);
if ($exif_data !== false) {
if (isset($exif_data['DateTimeOriginal'])) {
$date = $exif_data['DateTimeOriginal'];
}
if (empty($date) && isset($exif_data['DateTime'])) {
$date = $exif_data['DateTime'];
}
$this->logger->debug("exif date of " . $fileName . " : " . $date);
}
}
$item["date"] = $date == null ? date("Y-M-d H:i:s") : $date;
// resize in 4 sizes
$this->samplePicture($fileName);
// compute ratio
$image_info = getimagesize(sprintf('%s/%s', $this->dir, $fileName));
$item["ratio"] = $image_info[0] / $image_info[1];
$item["reverseRatio"] = 1 / $item["ratio"];
return $this->insert($item);
}
开发者ID:astranchet,项目名称:wallblog,代码行数:26,代码来源:PictureService.php
示例13: file
public function file()
{
$fileID = array_keys($_GET);
$fileID = str_replace('files/', '', $fileID[0]);
$fileInfo = $this->_files->getFileInfo($fileID);
if (empty($fileInfo)) {
header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
$data['title'] = '404';
$data['error'] = "Страница не найдена.";
View::render('Error/404');
die;
}
$data['title'] = $fileInfo['file_name'];
$data['fileinfo'] = $fileInfo;
if ($data['fileinfo']['file_type'] == 'image/jpg' || $data['fileinfo']['file_type'] == 'image/gif' || $data['fileinfo']['file_type'] == 'image/png') {
$data['imageinfo'] = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']);
}
if ($data['fileinfo']['file_type'] == 'image/jpg' || $data['fileinfo']['file_type'] == 'image/tiff') {
$data['imageinfo']['saved'] = exif_read_data($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']);
}
$fileType = array_shift(explode('/', $data['fileinfo']['file_type']));
if ($fileType == 'video' || $fileType == 'audio') {
$getID3 = new GetId3();
$data['mediainfo'] = $getID3->setEncoding('UTF-8')->analyze($_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $data['fileinfo']['server_name']);
}
$data['comments'] = $this->_files->getAllComments($fileID);
$data['token'] = $this->makeToken();
View::renderTemplate('header', $data);
View::render('files/file', $data);
View::renderTemplate('footer', $data);
}
开发者ID:Nattpyre,项目名称:rocketfiles,代码行数:31,代码来源:Files.php
示例14: flickr_photos_exif_read
function flickr_photos_exif_read(&$photo)
{
$map = flickr_photos_media_map();
if ($map[$photo['media']] == 'video') {
return not_okay("video does not contain EXIF data");
}
$fname = "{$photo['id']}_{$photo['originalsecret']}_o.{$photo['originalformat']}";
$froot = $GLOBALS['cfg']['flickr_static_path'] . flickr_photos_id_to_path($photo['id']);
$path = "{$froot}/{$fname}";
if (!preg_match("/\\.jpe?g\$/i", $path)) {
return not_okay("not a JPEG photo");
}
if (!file_exists($path)) {
return not_okay("original photo not found");
}
if (!filesize($path)) {
return not_okay("original photo is empty");
}
# TO DO: cache me?
$exif = exif_read_data($path);
if (!$exif) {
return not_okay("failed to read EXIF data");
}
# TO DO: expand EXIF tag values
$to_simplejoin = array('SubjectLocation', 'GPSLatitude', 'GPSLongitude', 'GPSTimeStamp');
foreach ($to_simplejoin as $tag) {
if (is_array($exif[$tag])) {
$exif[$tag] = implode(",", $exif[$tag]);
}
}
# TO DO: work out how/where individual EXIF tags get
# "prettified" ...
ksort($exif);
return okay(array("rows" => $exif));
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:35,代码来源:lib_flickr_photos_exif.php
示例15: auto_rotate
/**
* Automatically rotate an image based on EXIF data. If the
* IFD0[Orientation] header is available, this function will use
* it to rotate the image to the correct orientation.
*
* @param string $srcType MIME type of the source file
* @param string $srcFile Source filename
* @param string $dstFile Destination filename, can be the same as $srcFile
*/
function auto_rotate($srcType, $srcFile, $dstFile, $angle)
{
if (!extension_loaded('exif')) {
trigger_error("ppImage::auto_rotate() requires the exif PHP extension.");
return false;
}
$exif = exif_read_data($srcFile);
if ($exif == false) {
return false;
}
if (!isset($exif['IFD0']['Orientation'])) {
return false;
}
$rotate = 0;
$flip = false;
switch ($o) {
case 1:
$rotate = 0;
$flip = false;
break;
case 2:
$rotate = 0;
$flip = true;
break;
case 3:
$rotate = 180;
$flip = false;
break;
case 4:
$rotate = 180;
$flip = true;
break;
case 5:
$rotate = 90;
$flip = true;
break;
case 6:
$rotate = 90;
$flip = false;
break;
case 7:
$rotate = 270;
$flip = true;
break;
case 8:
$rotate = 270;
$flip = false;
break;
}
if ($flip) {
$this->flip($srcType, $srcFile, $srcFile, IMAGE_FLIP_HORIZONTAL);
}
if ($rotate) {
$this->rotate($srcType, $srcFile, $srcFile, $rotate);
}
if ($srcFile != $dstFile) {
copy($srcFile, $dstFile);
}
return true;
}
开发者ID:jvinet,项目名称:pronto,代码行数:69,代码来源:image.php
示例16: 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
示例17: 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
示例18: fix
function fix($path)
{
$image = imagecreatefromjpeg($path);
$exif = exif_read_data($path);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 1:
break;
case 2:
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 4:
imageflip($image, IMG_FLIP_VERTICAL);
break;
case 5:
$image = imagerotate($image, 90, 0);
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
case 7:
$image = imagerotate($image, -90, 0);
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 8:
$image = imagerotate($image, 90, 0);
break;
}
imagejpeg($image, $path);
}
}
开发者ID:robertblackwell,项目名称:srmn,代码行数:35,代码来源:OrientationFixer.php
示例19: fixImageOrientation
function fixImageOrientation($path)
{
$info = getimagesize($path);
if ($info['mime'] != "image/jpeg") {
return;
}
$exif = exif_read_data($path);
if (exif_imagetype($path) != IMAGETYPE_JPEG) {
return;
}
if (empty($exif['Orientation'])) {
return;
}
$image = imagecreatefromjpeg($path);
switch ($exif['Orientation']) {
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
case 8:
$image = imagerotate($image, 90, 0);
break;
}
imagejpeg($image, $path);
}
开发者ID:krombox,项目名称:motion,代码行数:27,代码来源:ImageTypeExtension.php
示例20: process
function process($mimeData, $parameters = array())
{
$printInfo = false;
if (isset($parameters['print_info'])) {
$printInfo = $parameters['print_info'];
}
$filename = $mimeData['url'];
if (file_exists($filename)) {
if (function_exists('exif_read_data')) {
$exifData = exif_read_data($filename, "COMPUTED,IFD0,COMMENT,EXIF", true);
if ($exifData) {
$info = array();
if (isset($exifData['COMPUTED'])) {
foreach ($exifData['COMPUTED'] as $key => $item) {
if (strtolower($key) == 'html') {
continue;
}
$info[$key] = $exifData['COMPUTED'][$key];
}
}
if (isset($exifData['IFD0'])) {
$info['ifd0'] = $exifData['IFD0'];
}
if (isset($exifData['EXIF'])) {
$info['exif'] = $exifData['EXIF'];
}
return $info;
}
}
}
return false;
}
开发者ID:legende91,项目名称:ez,代码行数:32,代码来源:ezexifimageanalyzer.php
注:本文中的exif_read_data函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论