本文整理汇总了PHP中create_thumb函数的典型用法代码示例。如果您正苦于以下问题:PHP create_thumb函数的具体用法?PHP create_thumb怎么用?PHP create_thumb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_thumb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: avatar_post
public function avatar_post($id)
{
$tempImage = tempnam_sfx(sys_get_temp_dir(), "jpg");
$imageName = base64_to_png($this->post('image'), $tempImage);
$thumbImage = create_thumb($imageName);
$nameThumb = name_thumb($imageName);
$handle = fopen($imageName, "r");
$data = fread($handle, filesize($imageName));
$headers = array('Authorization: Client-ID ' . IMGUR_CLIENT_ID);
$postFields = array('image' => base64_encode($data));
$dataImage = send_post(IMGUR_URL_UPLOAD_IMAGE, $postFields, $headers);
$handle = fopen($nameThumb, "r");
$data = fread($handle, filesize($nameThumb));
$headers = array('Authorization: Client-ID ' . IMGUR_CLIENT_ID);
$postFields = array('image' => base64_encode($data));
$dataThumb = send_post(IMGUR_URL_UPLOAD_IMAGE, $postFields, $headers);
$val['avatar_thumbnail'] = $dataThumb['data']['link'];
$val['avatar_standar'] = $dataImage['data']['link'];
$userId = $this->user_model->update($id, $val);
if (!is_null($userId)) {
//unlink($imageName);
//unlink($nameThumb);
$this->response(array('avatars' => $val), 200);
} else {
$this->response(array('error' => 'Internal Server Error'), 500);
}
}
示例2: upload_image
function upload_image($image, $target, $thumb = array('dest' => '', 'size' => array('w' => 257, 'h' => 218), 'ratio' => false), $prev_img = NULL)
{
$CI =& get_instance();
initialize_upload($target);
if ($CI->upload->do_upload($image)) {
if ($prev_img) {
if (is_file($target . $prev_img)) {
@unlink($target . $prev_img);
}
}
$data = $CI->upload->data();
$image = $data['file_name'];
$image_path = $data['full_path'];
$image_name = $data['raw_name'];
$image_ext = $data['file_ext'];
if ($thumb) {
//$thumb_size = array('w' => 200, 'h' =>220);
if ($thumb['dest']) {
$dest = $thumb['dest'];
} else {
$dest = $target;
}
create_thumb($image_path, $dest . $image, $thumb['size'], $thumb['ratio']);
}
return $image;
} else {
$CI->session->set_flashdata('error_message', $CI->upload->display_errors());
return false;
//return $CI->upload->display_errors();
}
}
示例3: update_employer_status
function update_employer_status()
{
if ($this->input->post('feature_in_slider') == '1') {
$image_file = $this->user_model->get_image($this->input->post('id'));
if (!file_exists("./uploads/user/images/banner/" . $image_file['image'])) {
$this->load->helper('image_helper');
$file_path = "./uploads/user/images/" . $image_file['image'];
$image = create_image_from_any($file_path);
//create image object to create thumbnail for the slider
$image_param = array('image' => $image_file['image'], 'image_loc' => "./uploads/user/images/", 'thumb_loc' => "./uploads/user/images/banner/", 'thumb_w' => BANNER_W, 'thumb_h' => BANNER_H, 'master_dim' => 'height');
create_thumb($image_param);
}
}
$this->user_model->update_employer_status();
echo 'success';
exit;
}
示例4: is_picture
function is_picture($picture_filename, $galid)
{
global $config;
$picture_path = $config['gallery_path'] . "/{$galid}/{$picture_filename}";
$thumbnail_path = $config['gallery_path'] . "/{$galid}/_thb_{$picture_filename}";
// check filename patterns
if (eregi("^_thb_*", $picture_filename) || !eregi(".jpg\$", $picture_filename) && !eregi(".png\$", $picture_filename) && !eregi(".gif\$", $picture_filename)) {
return false;
}
// does it exist, is it a regular file and does it have the expected permissions ?
if (!check_perms($picture_path)) {
return false;
}
// an associated thumbnail is required... same job again !
if (!check_perms($thumbnail_path)) {
create_thumb($picture_path, $thumbnail_path, 100);
}
return true;
}
示例5: save_pic
function save_pic($url, $nick, $comment, $saved_file, $ext)
{
global $fetch_log;
$file_name = md5_file($saved_file);
$path = STORAGE_PATH . $file_name . '.' . $ext;
rename($saved_file, $path);
$thumb_path = THUMB_PATH . $file_name . '.jpg';
list($w, $h) = create_thumb($path, $thumb_path);
chmod($path, 0664);
chmod($thumb_path, 0664);
$pic = new Pic(array('nick' => $nick, 'original_url' => $url, 'path' => $path, 'comment' => $comment, 'thumb' => $thumb_path, 'width' => $w, 'height' => $h, 'ctime' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));
if (ORM::all('pic', array('checksum' => $pic->checksum))->count() === 0) {
if ($pic->save()) {
file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tpic save SUCCESS\t{$url}\n", FILE_APPEND);
} else {
file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\terror saving image: " . var_export($pic->errors(), true) . "\t{$url}\n", FILE_APPEND);
}
} else {
file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tduplicate image\t{$url}\n", FILE_APPEND);
}
}
示例6: UploadImage
public function UploadImage($imgdata, $folder = 'Temp')
{
$base_dir = WWW_ROOT . DS . 'files/' . $folder;
if (!is_dir($base_dir)) {
mkdir($base_dir, 0755, true);
}
$arr_img = explode(".", $imgdata["name"]);
$ext = strtolower($arr_img[count($arr_img) - 1]);
if ($imgdata['error'] == 0 && in_array($ext, array('jpg', 'gif', 'png'))) {
$fname = removeSpecialChar($imgdata['name']);
$file = time() . "_" . $fname;
if (upload_my_file($imgdata['tmp_name'], $base_dir . '/' . $file)) {
$save_path = "thumb_" . $file;
create_thumb($base_dir . '/' . $file, 150, $base_dir . '/' . $save_path);
$array = array('image' => $file, 'thumb' => $save_path);
return $array;
} else {
return '0';
}
} else {
return '0';
}
}
示例7: draw_video_modal
function draw_video_modal($videos)
{
?>
<div class="modal fade" id="videos-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Video</h4>
</div>
<div class="modal-body" id="videos-sort-container">
<div id="videos-sort">
<?php
if (isset($videos) && $videos) {
foreach ($videos->result() as $video) {
?>
<div id="video-thumb-<?php
echo $video->id;
?>
" class="video-form form-inline" data-img-url="<?php
echo base_url() . str_replace('./', '', create_thumb($video->thumb, 746, 439));
?>
" role="form">
<div class="image-wrapper form-group"><img src="<?php
echo base_url() . str_replace('./', '', create_thumb($video->thumb, 211, 126));
?>
" width="211" height="126" alt=""/></div>
<div class="image-title form-group">
<input type="text" name="video-url[<?php
echo $video->id;
?>
]" value="<?php
echo $video->url;
?>
" class="form-control" placeholder="Youtube URL"/>
<span class="image-control">
<button type="button" class="btn btn-primary btn-sm save-video">Save</button>
<button type="button" class="btn btn-danger btn-sm delete-video">Delete</button>
<span class="spinner"></span>
</span>
</div>
</div>
<?php
}
}
?>
</div>
</div>
<div class="modal-footer">
<a id="upload_video_thumb" href="#" class="btn btn-primary btn-sm active pull-left" role="button">Add Video</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<span class="spinner"></span>
<p class="clearfix" style="text-align: left; margin-top: 10px;">Press Add Video button to select your video thumbnail and then place Youtube URL.<br /><b>Note:</b> Maximum video thumbnail size is 10MB, width 1024px and height 768px. Only jpg/jpeg/png allowed. Best Dimension 746x439px.</p>
</div>
</div>
</div>
</div>
<?php
}
示例8: get_ext
if (!isset($_POST['x']) || !isset($_POST['y']) || !isset($_POST['src'])) {
die;
}
$x = $_POST['x'];
$y = $_POST['y'];
$path_prestr = '../../';
$img_path = $path_prestr . $_POST['src'];
$img_ext = get_ext($img_path);
$img_size = @getimagesize($img_path);
$new_width = trim($_POST['w']);
$new_weight = trim($_POST['h']);
$size_ischanged = 0;
//是否对图片进行了缩放
if ($img_size[0] != $new_width) {
$tmp_path = str_replace('.' . $img_ext, '_tmp.' . $img_ext, $img_path);
if (create_thumb($img_path, $tmp_path, $new_width, $new_weight)) {
$img_path = $tmp_path;
$size_ischanged = 1;
} else {
exit;
}
}
$ico_path = str_replace('.' . $img_ext, '_ico.' . $img_ext, $img_path);
$temp_img = '';
if ($img_ext == 'jpg' || $img_ext == 'jpeg') {
$temp_img = imagecreatefromjpeg($img_path);
}
if ($img_ext == 'gif') {
$temp_img = imagecreatefromgif($img_path);
}
if ($img_ext == 'png') {
示例9: escape
$editclanname = @escape($_POST['editclanname'], 'string');
$editurl = escape($_POST['editwebsite'], 'url');
$editnation = escape($_POST['editnation'], 'string');
$editicq = escape($_POST['editicq'], 'integer');
$editemail = escape_for_email($_POST['editemail']);
$updir = 'include/images/opponents/';
$this_id = $getid;
$outar['thumbwidth'] = 100;
if (!empty($_FILES['editlogo']['tmp_name'])) {
$uploadname = $getid . '_' . $_FILES["editlogo"]["name"];
if ($getpicname != '.no-image-opponent.png' and $getpicname != 'thumb_.no-image-opponent.png') {
@unlink('include/images/opponents/' . $getpicname . '');
@unlink('include/images/opponents/thumb_' . $getpicname . '');
}
move_uploaded_file($_FILES["editlogo"]["tmp_name"], $updir . $uploadname);
create_thumb($updir . $uploadname, $updir . 'thumb_' . $uploadname, $outar['thumbwidth']);
} else {
$uploadname = $getpicname;
}
// DB UPDATE
db_query("UPDATE `prefix_opponents` SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tname \t= '" . $editclanname . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ttag \t= '" . $editclantag . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tpage \t= '" . $editurl . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\temail \t= '" . $editemail . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ticq \t= '" . $editicq . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tnation \t= '" . $editnation . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tlogo \t= '" . $uploadname . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tid = " . $getid . "");
wd('admin.php?opponents', 'Daten gespeichert', 3);
$design->footer(1);
}
$outar['ANTISPAM'] = get_antispam('adminuser_action', 0, true);
$tpl->set_ar_out($outar, 1);
$design->footer();
}
break;
default:
// Gegnerliste ausgeben
示例10: array
$photos_ext_accept = array('jpg','gif','png','jpeg');
if(in_array(strtolower(file_extension($_FILES['photo_file']['name'][$i])),$photos_ext_accept)){
$fl = new save_file($_FILES['photo_file']['tmp_name'][$i],$upload_folder,$_FILES['photo_file']['name'][$i]);
if($fl->status){
$file_saved = $fl->saved_filename;
if($default_uploader_chmod){@chmod(CWD . "/". $file_saved,$default_uploader_chmod);}
$thumb_saved = create_thumb($file_saved,$settings['photos_thumb_width'],$settings['photos_thumb_hieght'],true);
if($default_uploader_chmod){@chmod(CWD . "/". $thumb_saved,$default_uploader_chmod);}
db_query("insert into photos_data (name,img,thumb,cat,date) values('$name[$i]','$file_saved','$thumb_saved','$cat',now())");
}else{
$err_msg .= "<b> $phrases[error] : </b> $phrases[the_file] ".$_FILES['photo_file']['name'][$i]." : ".$fl->last_error_description." <br>" ;
}
}else{
$err_msg .= "<b> $phrases[error] : </b> $phrases[the_file] ".$_FILES['photo_file']['name'][$i]." : $phrases[this_filetype_not_allowed] <br>" ;
}
}
示例11: update_exec
function update_exec()
{
if ($this->m_blogs->check_author($this->input->post('blog_id')) == 0) {
echo "go to hell";
} else {
//if user uploads an image
if ($_FILES['photo']['error'] == 0) {
//$new_post = $this->db->insert_id();
//set the config to upload the files -> config/upload.php
if (!$this->upload->do_upload('photo')) {
$a = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('log', $a['error']);
redirect('member/blog/update/' . $this->input->post('blog_id'));
} else {
$image_data = array('upload_data' => $this->upload->data());
//update blogs
$update = $this->m_blogs->update();
//update post
$this->m_posts->update();
//update tags
$data['post'] = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
//type_id:2 = blog
$this->m_tags->update($data['post']->ID);
//update image
//check if blog has photo in table photos
$a = $this->m_photos->read($data['post']->ID);
if (count($a) > 0) {
//yes, update
//remove the previous image(?)
$prev_image = $this->m_photos->read($data['post']->ID);
if (is_file('./uploads/' . $prev_image[0]->src)) {
unlink('./uploads/' . $prev_image[0]->src);
}
if (is_file('./uploads/thumbs/' . $prev_image[0]->thumb)) {
unlink('./uploads/thumbs/' . $prev_image[0]->thumb);
}
$thumb = create_thumb($image_data['upload_data']['file_name']);
$this->m_photos->update($data['post']->ID, $image_data['upload_data'], $thumb);
} else {
//no, insert
$thumb = create_thumb($image_data['upload_data']['file_name']);
$post_info = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
$this->m_photos->create($post_info->ID, $image_data['upload_data'], $thumb);
}
redirect('member/blog');
}
} else {
//if user doesn't upload an image, just update the database
//update blogs
$update = $this->m_blogs->update();
//update post
$this->m_posts->update();
//update tags
$post = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
//type_id:2 = blog
$ch_tag = $this->m_tags->read($post->ID);
if (!empty($ch_tag)) {
$this->m_tags->update($post->ID);
} else {
$this->m_tags->create($post->ID);
}
redirect('member/blog');
}
}
}
示例12: update_exec
function update_exec()
{
if ($this->m_projects->check_author($this->input->post('project_id')) == 0) {
#echo "go to hell";
redirect('denied');
} else {
$not_empty_upload = 0;
//upload loop (max 3 photos)
#foreach($_FILES['photo'] as $key => $value){
for ($i = 1; $i <= 3; $i++) {
//if user uploads an image
if (!empty($_FILES['photo' . $i]['name'])) {
//$new_post = $this->db->insert_id();
//set the config to upload the files -> config/upload.php
if (!$this->upload->do_upload('photo' . $i)) {
$a[] = array('error' => $this->upload->display_errors());
$errors = true;
#$a = array('error' => $this->upload->display_errors());
#$this->session->set_flashdata('log', $a['error']);
#redirect('member/blog/create');
} else {
#$image_data = array('upload_data' => $this->upload->data());
$files[] = $this->upload->data();
}
$not_empty_upload += 1;
}
}
if ($not_empty_upload == 0) {
//user doesn't uplaod anything
//update projects
$update = $this->m_projects->update();
//update post
$this->m_posts->update();
//update tags
$post = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
//type_id:3 = project
$ch_tag = $this->m_tags->read($post->ID);
if (!empty($ch_tag)) {
$this->m_tags->update($post->ID);
} else {
$this->m_tags->create($post->ID);
}
redirect('member/project');
} else {
if (isset($a) && count($a) == $not_empty_upload) {
#print_r($a);
$this->session->set_flashdata('log', $a[$not_empty_upload - 1]['error']);
redirect('member/project/update/' . $this->input->post('project_id'));
} elseif (isset($files)) {
#$image_data = array('upload_data' => $this->upload->data());
//update projects
$update = $this->m_projects->update();
//update post
$this->m_posts->update();
//update tags
$data['post'] = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
//type_id:3 = project
$this->m_tags->update($data['post']->ID);
foreach ($files as $r) {
$thumb = create_thumb($r['file_name']);
$post_info = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
$this->m_photos->create($post_info->ID, $r, $thumb);
#$thumb = create_thumb($r['file_name']);
#$this->m_photos->create($post_id,$r,$thumb);
}
/*
//update image
//check if project has photo in table photos
$a = $this->m_photos->read($data['post']->ID);
if(count($a)>0){
//yes, update
//remove the previous image(?)
$prev_image = $this->m_photos->read($data['post']->ID);
if(is_file('./uploads/'.$prev_image[0]->src)){
unlink('./uploads/'.$prev_image[0]->src);
}
if(is_file('./uploads/thumbs/'.$prev_image[0]->thumb)){
unlink('./uploads/thumbs/'.$prev_image[0]->thumb);
}
$thumb = create_thumb($image_data['upload_data']['file_name']);
$this->m_photos->update($data['post']->ID,$image_data['upload_data'],$thumb);
}else{
//no, insert
$thumb = create_thumb($image_data['upload_data']['file_name']);
$post_info = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
$this->m_photos->create($post_info->ID,$image_data['upload_data'],$thumb);
}
*/
redirect('member/project');
}
}
}
}
示例13: _delete_video
function _delete_video()
{
$response = array('success' => FALSE);
if ($this->input->post()) {
$this->form_validation->set_rules('user_id', 'User ID', 'trim|required');
$this->form_validation->set_rules('template_id', 'Template ID', 'trim|required');
$this->form_validation->set_rules('id', 'Video ID', 'trim|required');
if ($this->form_validation->run() == TRUE) {
$video_id = preg_replace("/[^0-9]/", "", $this->input->post('id'));
$this->db->where('id', $video_id);
$this->db->where('template_id', (int) $this->input->post('template_id'));
$query = $this->db->get('template_videos');
if ($query->num_rows() > 0) {
$row = $query->row();
$this->db->where('id', $video_id);
$this->db->where('template_id', (int) $this->input->post('template_id'));
$this->db->delete('template_videos');
$response = array('success' => TRUE);
unlink(create_thumb($row->thumb, 211, 126));
unlink(create_thumb($row->thumb, 746, 439));
unlink($row->thumb);
}
}
}
echo json_encode($response);
exit;
}
示例14: intval
@chmod($file_path, 0644);
//创建缩略图
$sthumb_width = intval($config['sthumb_width']);
$sthumb_height = intval($config['sthumb_height']);
$sthumb_width = 0 >= $sthumb_width ? null : $sthumb_width;
$sthumb_height = 0 >= $sthumb_height ? null : $sthumb_height;
if ($sthumb_width && $sthumb_height) {
create_thumb($file_path, $file_ext, $sthumb_width, $sthumb_height);
} else {
if (empty($sthumb_width) && $sthumb_height) {
create_thumb($file_path, $file_ext, null, $sthumb_height);
} else {
if ($sthumb_width && empty($sthumb_height)) {
create_thumb($file_path, $file_ext, $sthumb_width);
} else {
create_thumb($file_path, $file_ext);
}
}
}
$file_url = $save_url . $new_file_name;
header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 0, 'url' => $file_url));
exit;
}
function alert($msg)
{
header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 1, 'message' => $msg));
exit;
示例15: upload_img_file
public function upload_img_file($arr, $id)
{
$fileUpload = WWW_ROOT . 'files' . DS . $id;
if (!is_dir($fileUpload)) {
mkdir($fileUpload, 0777);
}
if (!is_dir($fileUpload . '/thumb')) {
mkdir($fileUpload . '/thumb', 0777);
}
if (!is_dir($fileUpload . '/minithumb')) {
mkdir($fileUpload . '/minithumb', 0777);
}
$fname = removeSpecialChar($arr['name']);
$file = time() . "_" . $fname;
if (upload_my_file($arr['tmp_name'], $fileUpload . '/' . $file)) {
$save_path = "thumb_" . $file;
$min_save_path = "mini_thumb_" . $file;
create_thumb($fileUpload . '/' . $file, 150, $fileUpload . '/thumb/' . $save_path);
create_thumb($fileUpload . '/' . $file, 42, $fileUpload . '/minithumb/' . $min_save_path);
return $file;
} else {
return 0;
}
}