Esempio n. 1
0
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as 
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
require "cropImage.class.php";
$image_src = $_POST["image"];
$new_image_src = "thumb/thumb-" . basename($image_src);
$width = intval($_POST["width"]);
$height = intval($_POST["height"]);
$x = intval($_POST["x"]);
$y = intval($_POST["y"]);
/* Set options */
$options = array('image_src' => $image_src, 'new_image_src' => $new_image_src, 'width' => $width, 'height' => $height, 'x' => $x, 'y' => $y);
$cropImage = new cropImage($options);
?>
<h3>Cropped image saved in the folder thumb :)</h3>
<hr />
<img src="<?php 
echo $cropImage->getNewImage();
?>
" />
Esempio n. 2
0
 function createcropedavatar()
 {
     //require_once WRA_Path."/modules/cropcanvas/class.cropcanvas.php";//обрезка изображений
     //require_once WRA_Path."/modules/cropcanvas/class.cropinterface.php";//обрезка изображений
     if ($this->error != "") {
         return;
     }
     $this->tmbfilename = "tmb_" . $this->filename;
     $this->getimageinfo();
     if ($this->imageheight >= $this->imagewidth) {
         $image_info = getimagesize($this->uploaddir . $this->filename);
         $image_type = $image_info[2];
         $image = "";
         if ($image_type == IMAGETYPE_JPEG) {
             $image = imagecreatefromjpeg($this->uploaddir . $this->filename);
         } elseif ($this->image_type == IMAGETYPE_GIF) {
             $image = imagecreatefromgif($this->uploaddir . $this->filename);
         } elseif ($this->image_type == IMAGETYPE_PNG) {
             $image = imagecreatefrompng($this->uploaddir . $this->filename);
         }
         $newheight = $this->imageheight / $this->imagewidth * $this->tmbwidth;
         $new_image = imagecreatetruecolor($this->tmbwidth, $newheight);
         imagecopyresampled($new_image, $image, 0, 0, 0, 0, $this->tmbwidth, $newheight, $this->imagewidth, $this->imageheight);
         $image = $new_image;
         $cc = new cropImage();
         $cc->setImage($new_image, $this->tmbwidth, $newheight);
         $cc->createThumb($this->tmbwidth);
         $image = $cc->myImage;
         if ($image_type == IMAGETYPE_JPEG) {
             imagejpeg($image, $this->uploaddir . $this->tmbfilename, $this->tmbcompr);
         } elseif ($image_type == IMAGETYPE_GIF) {
             imagegif($image, $this->uploaddir . $this->tmbfilename);
         } elseif ($image_type == IMAGETYPE_PNG) {
             imagepng($image, $this->uploaddir . $this->tmbfilename);
         }
     } elseif ($this->imageheight < $this->imagewidth) {
         $image_info = getimagesize($this->uploaddir . $this->filename);
         $image_type = $image_info[2];
         $image = "";
         if ($image_type == IMAGETYPE_JPEG) {
             $image = imagecreatefromjpeg($this->uploaddir . $this->filename);
         } elseif ($this->image_type == IMAGETYPE_GIF) {
             $image = imagecreatefromgif($this->uploaddir . $this->filename);
         } elseif ($this->image_type == IMAGETYPE_PNG) {
             $image = imagecreatefrompng($this->uploaddir . $this->filename);
         }
         $newheight = $this->imagewidth / $this->imageheight * $this->tmbwidth;
         $new_image = imagecreatetruecolor($newheight, $this->tmbwidth);
         imagecopyresampled($new_image, $image, 0, 0, 0, 0, $newheight, $this->tmbwidth, $this->imagewidth, $this->imageheight);
         $image = $new_image;
         $cc = new cropImage();
         $cc->setImage($new_image, $newheight, $this->tmbwidth);
         $cc->createThumb($this->tmbwidth);
         $image = $cc->myImage;
         if ($image_type == IMAGETYPE_JPEG) {
             imagejpeg($image, $this->uploaddir . $this->tmbfilename, $this->tmbcompr);
         } elseif ($image_type == IMAGETYPE_GIF) {
             imagegif($image, $this->uploaddir . $this->tmbfilename);
         } elseif ($image_type == IMAGETYPE_PNG) {
             imagepng($image, $this->uploaddir . $this->tmbfilename);
         }
     } else {
         copy($this->uploaddir . $this->filename, $this->uploaddir . $this->tmbfilename);
     }
 }