Пример #1
0
 function setcontentsource($source, $x, $y, $width, $height, $bestfit = true)
 {
     $myimage = new Gmagick();
     $myimage->readimageblob($source);
     $myimage->thumbnailImage($width, $height, $bestfit);
     $this->im->compositeImage($myimage, gmagick::COMPOSITE_OVER, $x, $y);
     //图片与画布合成
     $myimage->clear();
     $myimage->destroy();
     //释放资源
 }
Пример #2
0
 function generate_thumbnail($originName, $thumbnailName, $path, $width = 255, $height = 255)
 {
     // use third part toolkit to process photos
     // TODO
     // Instantiate a new Gmagick object
     $image = new Gmagick('/var/www/html/ant/uploads/mv.jpg');
     // Make thumbnail from image loaded. 0 for either axes preserves aspect ratio
     //$image->thumbnailImage(150, 0);
     $image->thumbnailImage($width, $height);
     // Create a border around the image, then simulate how the image will look like as an oil painting
     // Notice the chaining of mutator methods which is supported in gmagick
     // $image->borderImage("yellow", 8, 8)->oilPaintImage(0.3);
     // Write the current image at the current state to a file
     // $image->write('/var/www/html/ant/uploads/example_thumbnail.jpg');
     $image->write('example_thumbnail.jpg');
 }
Пример #3
0
<?php

//Instantiate a new Gmagick object
$image = new Gmagick('example.jpg');
//Make thumbnail from image loaded. 0 for either axes preserves aspect ratio
$image->thumbnailImage(100, 0);
//Create a border around the image, then simulate how the image will look like as an oil painting
//Notice the chaining of mutator methods which is supported in gmagick
$image->borderImage("yellow", 8, 8)->oilPaintImage(0.3);
//Write the current image at the current state to a file
$image->write('example_thumbnail.jpg');
Пример #4
0
 /**
  * Resize the image if it exceed max allowed sizes
  *
  * @param string $source the source image
  * @param string $dest   the destination image.
  * @param string $format the format to use
  *
  * @return void
  */
 public function resize($source, $dest, $format)
 {
     $image = new \Gmagick();
     $fmts = $this->conf->getFormats();
     $fmt = $fmts[$format];
     $h = $fmt['height'];
     $w = $fmt['width'];
     try {
         $image->readImage($source);
         $image->thumbnailImage($w, $h, true);
         $image->writeImage($dest);
     } catch (\GmagickException $e) {
         $image->destroy();
         throw new \RuntimeException($e->getMessage());
     }
     $image->destroy();
 }
Пример #5
0
                        }
                    }
                }
            }
            // Edit upload location here
            $destination_path = 'files/users/';
            $target_path = $destination_path . $name;
            $Thumb_Path = $destination_path . 'thumbs/' . $name;
            if (@move_uploaded_file($_FILES['userimg']['tmp_name'], $target_path)) {
                $result = 1;
                $sql = execute_sqlQuery("UPDATE tblAppUsers SET userImage='{$name}' WHERE empl_id='{$uid}'");
                try {
                    // initialize object
                    $image = new Gmagick();
                    $image->readImage($target_path);
                    $image->thumbnailImage(55, 55);
                    $image->writeImage($Thumb_Path);
                    // free resource handle
                    $image->destroy();
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
        }
    }
}
header("Location:edituser.php?res={$result}&er={$er}");
?>