Example #1
0
 function v($b64_user_id, $image_name, $side_length = -1, $fill_blank = false)
 {
     $user_id = decode_uuid_base64($b64_user_id);
     $orignal_image_path = UPLOAD_BASE_PATH . $user_id . DIRECTORY_SEPARATOR . $image_name;
     if ($side_length > 0) {
         if ($fill_blank == 2) {
             $filename = create_square_thumbnail_image($orignal_image_path, $side_length);
         } else {
             if ($fill_blank) {
                 $filename = create_filled_image($orignal_image_path, $side_length);
             } else {
                 $filename = create_resized_image($orignal_image_path, $side_length);
             }
         }
     } else {
         $filename = $orignal_image_path;
     }
     if ($filename && file_exists($filename)) {
         header('Content-Length: ' . filesize($filename));
         // <-- sends filesize header
         header('Content-Type: image/jpg');
         // <-- send mime-type header
         header('Content-Disposition: inline; filename="' . $filename . '";');
         // <-- sends filename header
         readfile($filename);
         // <--reads and outputs the file onto the output buffer
         die;
         // <--cleanup
         exit;
         // and exit
     } else {
         redirect(base_url('noimage.jpg'));
         // show_404 ();
     }
 }
Example #2
0
 function v($image_name, $side_length = 0, $fill_blank = false)
 {
     $orignal_image_path = HEAD_IMG_BASE_PATH . $image_name;
     log_message('debug', "{$image_name}/{$side_length}/{$fill_blank}");
     if ($side_length > 0) {
         if ($fill_blank) {
             $filename = create_filled_image($orignal_image_path, $side_length);
         } else {
             $filename = create_resized_image($orignal_image_path, $side_length);
         }
     } else {
         $filename = $orignal_image_path;
     }
     if ($filename && file_exists($filename) && filesize($filename)) {
         header('Content-Length: ' . filesize($filename));
         // <-- sends filesize header
         header('Content-Type: image/jpg');
         // <-- send mime-type header
         header('Content-Disposition: inline; filename="' . $filename . '";');
         // <-- sends filename header
         readfile($filename);
         // <--reads and outputs the file onto the output buffer
         die;
         // <--cleanup
         exit;
         // and exit
     } else {
         redirect(base_url('noimage.jpg'));
         // show_404 ();
     }
 }
Example #3
0
 function create_square_thumbnail_image($source_image_path, $side_length, $force_create = false)
 {
     if (!file_exists($source_image_path)) {
         return NULL;
     }
     $square_image_path = create_square_image($source_image_path, $force_create);
     if (!$square_image_path) {
         return NULL;
     }
     return create_resized_image($square_image_path, $side_length, $force_create);
 }