$filepath = $video['filepath']; findOneFile($filename, $root_path . $video_path); if (file_exists($root_path . $video_path . "/" . $filename)) { $filename_arr = explode(".", $filename); $pic_name = $filename_arr[0]; $new_file = $root_path . '/public/data/images/video/cut/' . $pic_name . '.jpg'; $ffmpeg_cmd = '/data/software/simple-rtmp-server/trunk/objs/ffmpeg/bin/ffmpeg -y -i ' . $root_path . '/public/data/video/live/' . $filename . ' -ss 00:00:01 -f image2 -vframes 1 ' . $new_file; $ret = exec($ffmpeg_cmd); if (file_exists($new_file)) { $ext = "jpg"; $savePath = $root_path . "/public/data/images/video/cut/"; $saveName = $pic_name . '.jpg'; $ret = saveThumbImg_ex($ext, $savePath, $saveName, 187, 140, '187x140_'); saveThumbImg_ex($ext, $savePath, $saveName, 100, 75, '100x75_'); saveThumbImg_ex($ext, $savePath, $saveName, 120, 90, '120x90_'); $ret = saveThumbImg_ex($ext, $savePath, $saveName, 85, 64, '85x64_'); if ($ret == 0) { $data = array('vid' => $id, 'pic_name' => $saveName); $res = rcurl($api_url, $data); } } echo "####{$ret}#####"; } else { echo date() . "[ERROR]" . $root_path . $video_path . "/" . $filename . " not exist."; } } @unlink($filePath); } closedir($dh); } if ($c == 0) {
public function avatar() { $avatar = "http://tp4.sinaimg.cn/1772890455/50/5641353221/1"; $uid = "153030"; $targetPath = "public/data/images/header/" . checkfolder($uid); if (!is_dir($targetPath)) { mkdir($targetPath, 0777, true); } $filename_big = 'avatar_big_' . $uid; $filename = $targetPath . $filename_big; $img_info = downloadImage($avatar, $filename); var_export($img_info); $posfix = "jpg"; $filename_big = $img_info['filename']; $f = explode(".", $filename_big); if (isset($f[1])) { if ($f[1] != "jpg") { copy($img_info['filepath'], $filename . ".jpg"); if (!file_exists($filename . ".jpg")) { $posfix = $f[1]; } } } echo $posfix; $filename_middle = 'avatar_middle_' . $uid . '.' . $posfix; $result = saveThumbImg_ex($posfix, $targetPath, $filename_big, 200, 200); var_export($result); if (file_exists($targetPath . $filename_middle)) { unlink($targetPath . $filename_middle); } rename($targetPath . 'thumb_' . $filename_big, $targetPath . $filename_middle); $filename_small = 'avatar_small_' . $uid . '.' . $posfix; $result = saveThumbImg_ex($posfix, $targetPath, $filename_big, 50, 50); var_export($result); if (file_exists($targetPath . $filename_small)) { unlink($targetPath . $filename_small); } rename($targetPath . 'thumb_' . $filename_big, $targetPath . $filename_small); echo avatar($uid, $posfix); }
/** * 自动下载第三方图片 * @param array $data * @return boolean */ private function auto_save_avatar($uid, $avatar) { $targetPath = "public/data/images/header/" . checkfolder($uid); if (!is_dir($targetPath)) { mkdir($targetPath, 0777, true); } $filename_big = 'avatar_big_' . $uid; $filename = $targetPath . $filename_big; $img_info = downloadImage($avatar, $filename); /* $img_info['filepath'] = ""; $img_info['width'] = ""; $img_info['height'] = ""; $img_info['orginalfilename'] = ""; $img_info['filename'] = ""; $img_info['mime'] = ""; $img_info['size'] = ""; */ $posfix = "jpg"; $filename_big = $img_info['filename']; $f = explode(".", $filename_big); if (isset($f[1])) { if ($f[1] != "jpg") { copy($img_info['filepath'], $filename . ".jpg"); if (!file_exists($filename . ".jpg")) { $posfix = $f[1]; } } } $filename_middle = 'avatar_middle_' . $uid . '.' . $posfix; $result = saveThumbImg_ex($posfix, $targetPath, $filename_big, 200, 200); if (file_exists($targetPath . $filename_middle)) { unlink($targetPath . $filename_middle); } rename($targetPath . 'thumb_' . $filename_big, $targetPath . $filename_middle); $filename_small = 'avatar_small_' . $uid . '.' . $posfix; $result = saveThumbImg_ex($posfix, $targetPath, $filename_big, 50, 50); if (file_exists($targetPath . $filename_small)) { unlink($targetPath . $filename_small); } rename($targetPath . 'thumb_' . $filename_big, $targetPath . $filename_small); }