本文整理汇总了PHP中c2cTools::getFileType方法的典型用法代码示例。如果您正苦于以下问题:PHP c2cTools::getFileType方法的具体用法?PHP c2cTools::getFileType怎么用?PHP c2cTools::getFileType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c2cTools
的用法示例。
在下文中一共展示了c2cTools::getFileType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateWithExifDataFrom
/**
* Reads exif data in Image file (if available) and hydrates object with the most important of them.
* Also reads GPS info if set (for instance with gpscorrelate, a GPX file and a bunch of well-tagged pictures)
* see for instance http://freefoote.dview.net/linux_gpscorr.html
*
* @param $filename_with_path
* @param $overwrite_geom : if true, then image lon, lat and ele will be overwritten by those taken from the Exif data (if they exist).
*/
public function populateWithExifDataFrom($filename_with_path, $overwrite_geom = true, $overwrite_datetime = true)
{
// here, read eventual lon, lat and elevation in exif tag...
if (c2cTools::getFileType($filename_with_path) == 'jpg' && ($exif = exif_read_data($filename_with_path))) {
$lon = '';
$lat = '';
if (isset($exif['GPSLatitude']) && isset($exif['GPSLongitude']) && isset($exif['GPSLatitudeRef']) && isset($exif['GPSLongitudeRef']) && $overwrite_geom) {
if (strtoupper($exif['GPSLongitudeRef']) == "W") {
$lon = -1 * self::convertDMSToDecimal($exif['GPSLongitude']);
} else {
$lon = self::convertDMSToDecimal($exif['GPSLongitude']);
}
if (strtoupper($exif['GPSLatitudeRef']) == "S") {
$lat = -1 * self::convertDMSToDecimal($exif['GPSLatitude']);
} else {
$lat = self::convertDMSToDecimal($exif['GPSLatitude']);
}
// some images come with (0,0) coordinates. Skip such cases
// also skip obviously wrong values (it happens)
if ($lon != 0 && $lat != 0 && abs($lat) < 90 && abs($lon) < 180) {
$this->set('lon', $lon);
$this->set('lat', $lat);
}
}
$ele = '';
if (isset($exif['GPSAltitude']) && isset($exif['GPSAltitudeRef']) && $overwrite_geom) {
if ($exif['GPSAltitudeRef'] == "1") {
$ele = -1 * round(self::frac_to_dec($exif['GPSAltitude']));
} else {
$ele = round(self::frac_to_dec($exif['GPSAltitude']));
}
$this->set('elevation', $ele);
}
$camera_name = null;
if (isset($exif['Make']) && strtolower($exif['Make']) != 'canon') {
$camera_name = $exif['Make'];
}
if (isset($exif['Model'])) {
if (strtolower($exif['Make']) != 'canon') {
$camera_name .= ' ' . $exif['Model'];
} else {
$camera_name = $exif['Model'];
}
}
$this->set('camera_name', $camera_name);
if (isset($exif['DateTimeOriginal']) && $overwrite_datetime) {
$image_date = str_replace(' ', ':', $exif['DateTimeOriginal']);
$image_date = explode(':', $image_date);
$image_date = mktime($image_date[3], $image_date[4], $image_date[5], $image_date[1], $image_date[2], $image_date[0]);
$this->set('date_time', date('c', $image_date));
}
if (isset($exif['ExposureTime'])) {
$this->set('exposure_time', self::frac_to_dec($exif['ExposureTime']));
}
if (isset($exif['FNumber'])) {
$this->set('fnumber', self::frac_to_dec($exif['FNumber']));
}
if (isset($exif['ISOSpeedRatings'])) {
$iso_speed = is_array($exif['ISOSpeedRatings']) ? $exif['ISOSpeedRatings'][0] : $exif['ISOSpeedRatings'];
$this->set('iso_speed', $iso_speed);
}
if (isset($exif['FocalLength'])) {
$this->set('focal_length', self::frac_to_dec($exif['FocalLength']));
}
c2cTools::log("Image::populateWithExifDataFrom found GPS data in exif tag : {$lon}, {$lat}, {$ele}");
}
}
示例2: getWktFromFileUpload
/**
* Returns a 3D or 4D WKT
*/
protected function getWktFromFileUpload($request)
{
$path = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . c2cTools::generateUniqueName();
$status = $request->moveFile('gps_data', $path);
$type = c2cTools::getFileType($path);
c2cTools::log("File uploaded to: {$path} with status: {$status} and a file type of: {$type}");
$finalPath = $path;
$wkt = NULL;
// we rename file according to true type
// FIXME as for now we only accept gpx,
// this is kinda redundant...
if ($type) {
$status = rename($path, "{$path}.{$type}");
if ($status) {
$finalPath = $path . '.' . $type;
c2cTools::log("File renamed: {$finalPath}");
$wkt = $this->getWktFromFile($finalPath, $type);
c2cTools::log("wkt computed");
}
}
// we clear temp file :
unlink($finalPath);
//c2cTools::log("getWktFromFileUpload has generated this WKT: $wkt");
return $wkt;
}
示例3: detectExtension
/**
* Get file extension from a file path (eg. /tmp/photo.jpg) using file type info.
*
* @input string filepath
* @return string ext
**/
public static function detectExtension($filepath)
{
return '.' . c2cTools::getFileType($filepath);
}