예제 #1
0
<?php

include 'ImageProcessing.php';
$imageFileName = $_GET['image'];
$relativeImagePath = 'images/' . $imageFileName;
$test = ImageProcessing::GetImageInfo($relativeImagePath);
?>

<html>
<head></head>
<body>
<img src="<?php 
echo $relativeImagePath;
?>
">
<p style="font-family: sans-serif;"><?php 
echo $test->path;
?>
, <?php 
echo $test->format;
?>
, <?php 
echo $test->width;
?>
x<?php 
echo $test->height;
?>
</p>
<ul style="list-style:none; padding:0; margin:0;">
<?php 
foreach ($test->relevantColors as $rgb) {
예제 #2
0
파일: post.php 프로젝트: SimTabi/tribble
 public function reply($postId)
 {
     $session = $this->alternatesession->session_exists();
     if ($session) {
         $data['user'] = $session;
         $data['title'] = $this->config->item('site_name') . ' - Upload';
         $data['meta_description'] = $this->config->item('site_description');
         $data['meta_keywords'] = $this->config->item('site_keywords');
         if (!strpos($postId, '-')) {
             $slug = strlen($postId);
         } else {
             $slug = strpos($postId, '-');
         }
         $post_id = substr($postId, 0, $slug);
         //Pull in an array of tweets
         $post_data = $this->rest->get('posts/single/' . $post_id);
         $data['post'] = $post_data->post[0];
         $this->form_validation->set_error_delimiters('<p class="help">', '</p>');
         // check form submission and validate
         if ($this->form_validation->run('upload_image') == false) {
             //form has errors : show page and errors
             $this->load->view('common/page_top.php', $data);
             $this->load->view('post/reply.php', $data);
             $this->load->view('common/page_end.php', $data);
         } else {
             // get the uid from the session data and hash it to be used as the user upload folder name
             $user_hash = do_hash($session->user_email);
             // set the upload configuration
             $ulConfig['upload_path'] = './data/' . $user_hash . '/';
             $ulConfig['allowed_types'] = 'jpg|png';
             $ulConfig['max_width'] = '400';
             $ulConfig['max_height'] = '300';
             $ulConfig['encrypt_name'] = true;
             $ulConfig['overwrite'] = false;
             // load the file uploading lib and initialize
             $this->load->library('upload', $ulConfig);
             $this->upload->initialize($ulConfig);
             // check if upload was successful and react
             if (!$this->upload->do_upload('image_file')) {
                 $data['errors'] = array('message' => $this->upload->display_errors());
                 //form has errors : show page and errors
                 //form has errors : show page and errors
                 $this->load->view('common/page_top.php', $data);
                 $this->load->view('post/reply.php', $data);
                 $this->load->view('common/page_end.php', $data);
             } else {
                 $data = array('upload_data' => $this->upload->data());
                 // set the data to write in db;
                 $image_color_data = ImageProcessing::GetImageInfo($data['upload_data']['full_path']);
                 $imgdata = array('path' => substr($ulConfig['upload_path'] . $data['upload_data']['file_name'], 1), 'palette' => json_encode($image_color_data->relevantColors), 'ranges' => json_encode($image_color_data->relevantColorRanges));
                 $config['image_library'] = 'gd2';
                 $config['source_image'] = $ulConfig['upload_path'] . $data['upload_data']['file_name'];
                 $config['create_thumb'] = true;
                 $config['maintain_ratio'] = true;
                 $config['width'] = 200;
                 $config['height'] = 150;
                 $this->load->library('image_lib', $config);
                 $this->image_lib->resize();
                 $post_put_data = array('image_data' => $imgdata, 'post_title' => $this->input->post('post_title'), 'post_text' => $this->input->post('post_text'), 'post_tags' => $this->input->post('post_tags'), 'post_parent_id' => $this->input->post('post_parent_id'), 'user_id' => $session->user_id);
                 $post_put = $this->rest->put('reply/post', $post_put_data);
                 if ($post_put->request_status) {
                     redirect('/view/' . $post_put->post_id);
                 } else {
                     $this->rest->put('trash/throw', array('trash_path' => $imgdata['path']));
                     $data['title'] = $this->config->item('site_name');
                     $data['meta_description'] = $this->config->item('site_description');
                     $data['meta_keywords'] = $this->config->item('site_keywords');
                     $data['errors'] = array('message' => 'Something is broken. Let\'s all pray to the Mighty Carmona!');
                     //form has errors : show page and errors
                     $this->load->view('common/page_top.php', $data);
                     $this->load->view('post/reply.php', $data);
                     $this->load->view('common/page_end.php', $data);
                 }
             }
         }
     } else {
         redirect(site_url());
     }
 }
예제 #3
0
 function update_colors($limit, $offset)
 {
     $query = $this->db->get_where('image', array('image_color_ranges' => null), $limit, $offset);
     $res = $query->result();
     foreach ($res as $image) {
         $img_data = ImageProcessing::GetImageInfo($this->config->item('app_path') . $image->image_path);
         $data = array('image_palette' => json_encode($img_data->relevantColors), 'image_color_ranges' => json_encode($img_data->relevantColorRanges));
         $this->db->where('image_id', $image->image_id);
         $this->db->update('image', $data);
         var_dump($img_data->path);
     }
 }