public function show_exif() { if ($this->setting['open_exif']) { $img = base64_decode($_REQUEST['img']); if (function_exists(exif_read_data)) { $exif = GetImageInfo($img); //输出exif信息 $this->assign('exif', $exif); } else { //系统不支持 $error_info = '服务器不支持照片exif信息提取功能。'; $this->assign('error', $error_info); } } else { //系统不支持 $error_info = '管理员关闭了照片exif信息提取功能。'; $this->assign('error', $error_info); } $this->display(); }
$filePath = 'contact/' . $timeParam . $userId . '_' . md5_file($_FILES['photo']['tmp_name']) . '.' . end(explode('.', $_FILES['photo']['name'])); $filePathSmall = 'contact/' . $timeParam . $userId . '_' . md5_file($_FILES['photo']['tmp_name']) . '_s' . '.' . end(explode('.', $_FILES['photo']['name'])); #上传原图 file_put_contents(IMG_PATH_BASE . $filePath, file_get_contents($_FILES['photo']['tmp_name'])); #修正图片大小 require_once 'lib/photo.class.php'; $photoTool = new photo(); $photoInfo = $photoTool->getPhotoInfo(IMG_PATH_BASE . $filePath); if ($photoInfo['width'] > 600) { $rate = $photoInfo['width'] / 600; $photoInfo['width'] = 600; $photoInfo['height'] = ceil($photoInfo['height'] / $rate); } #根据照片exif信息决定是否旋转 require_once 'lib/exif.php'; $exifInfo = GetImageInfo(IMG_PATH_BASE . $filePath); if ($exifInfo['方向'] == 'right side top') { $photoTool->flip(IMG_PATH_BASE . $filePath, IMG_PATH_BASE . $filePath, -90); $widthTmp = $photoInfo['width']; $photoInfo['width'] = $photoInfo['height']; $photoInfo['height'] = $widthTmp; } unset($exifInfo); $photoTool->copyImageWithSize(IMG_PATH_BASE . $filePath, IMG_PATH_BASE . $filePathSmall, $photoInfo['width'], $photoInfo['height']); } $param['accessToken'] = $_COOKIE['accessToken']; $param['event'] = $_POST['event']; $param['id'] = $_POST['id']; if (isset($filePathSmall) && $filePathSmall) { $param['photo'] = $filePathSmall; }