function crop_picture_by_id() { @ob_clean(); $user_id = CI::model('core')->userId(); if (intval($user_id) == 0) { exit('Error! You are not logged in.'); } $id = $_POST['id']; if ($id > 0) { $media = CI::model('core')->mediaGetById($id); if (!empty($media)) { require 'ImageManipulation.php'; $file_path = MEDIAFILES . 'pictures/original/' . $media['filename']; $objImage = new ImageManipulation($file_path); if ($objImage->imageok) { $objImage->setCrop($_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']); //$objImage->resize(500); //$objImage->show(); $objImage->save($file_path); } else { echo 'Error!'; } } } // $src = 'flowers.jpg'; //exit (); exit; //var_dump ( $_POST ); }
$subPath = isset($_GET['path']) ? $_GET['path'] : ""; if ($subPath != '') { $subPath = tsl($subPath); } $src = strippath($_GET['i']); $thumb_folder = GSTHUMBNAILPATH . $subPath; $src_folder = '../data/uploads/'; $thumb_folder_rel = '../data/thumbs/' . $subPath; if (!is_file($src_folder . $subPath . $src)) { redirect("upload.php"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { require_once 'inc/imagemanipulation.php'; $objImage = new ImageManipulation($src_folder . $subPath . $src); if ($objImage->imageok) { $objImage->setCrop($_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']); //$objImage->show(); $objImage->save($thumb_folder . 'thumbnail.' . $src); $success = i18n_r('THUMB_SAVED'); } else { i18n('ERROR'); } } list($imgwidth, $imgheight, $imgtype, $imgattr) = getimagesize($src_folder . $subPath . $src); if (file_exists($thumb_folder . 'thumbnail.' . $src)) { list($thwidth, $thheight, $thtype, $athttr) = getimagesize($thumb_folder . 'thumbnail.' . $src); $thumb_exists = ' | <a href="' . $thumb_folder_rel . 'thumbnail.' . rawurlencode($src) . '" rel="facybox_i" >' . i18n_r('CURRENT_THUMBNAIL') . '</a> <code>' . $thwidth . 'x' . $thheight . '</code>'; } else { require_once 'inc/imagemanipulation.php'; genStdThumb($subPath, $src); list($thwidth, $thheight, $thtype, $athttr) = getimagesize($thumb_folder . 'thumbnail.' . $src);
redirect("upload.php"); } // handle jcrop thumbnail creation if ($_SERVER['REQUEST_METHOD'] == 'POST' && matchArrayAll(array('x', 'y', 'w', 'h'), array_keys($_POST))) { exec_action('image-crop'); $x = (int) $_POST['x']; $y = (int) $_POST['y']; $w = (int) $_POST['w']; $h = (int) $_POST['h']; $max = 10000; // set a max to prevent excessive processing injections if ($x < $max && $y < $max && $w < $max && $h < $max) { require_once 'inc/imagemanipulation.php'; $objImage = new ImageManipulation($src_folder . $subPath . $src); if ($objImage->imageok) { $objImage->setCrop($x, $y, $w, $h); $objImage->save($thumb_folder . 'thumbnail.' . $src); $success = i18n_r('THUMB_SAVED'); } else { $error = i18n('ERROR'); } } } $thumb_exists = $thwidth = $thheight = $thtype = $athttr = ''; list($imgwidth, $imgheight, $imgtype, $imgattr) = getimagesize($src_folder . $subPath . $src); if (file_exists($thumb_folder . 'thumbnail.' . $src)) { list($thwidth, $thheight, $thtype, $athttr) = getimagesize($thumb_folder . 'thumbnail.' . $src); $thumb_exists = ' | <a href="' . $thumb_url . 'thumbnail.' . rawurlencode($src) . '" rel="fancybox_i" >' . i18n_r('CURRENT_THUMBNAIL') . '</a> <code>' . $thwidth . 'x' . $thheight . '</code>'; } else { // if thumb is missing recreate it if (genStdThumb($subPath, $src)) {