コード例 #1
0
ファイル: bug38212.php プロジェクト: badlamer/hhvm
<?php

$file = dirname(__FILE__) . '/bug38212.gd2';
$im1 = imagecreatetruecolor(10, 100);
imagefill($im1, 0, 0, 0xffffff);
imagegd2($im1, $file);
$im = imagecreatefromgd2part($file, 0, 0, -25, 10);
unlink($file);
コード例 #2
0
ファイル: bug39286.php プロジェクト: badlamer/hhvm
<?php

$img = imagecreatefromgd2part("foo.png", 0, 100, 0, 100);
コード例 #3
0
ファイル: createfromgd2.php プロジェクト: badlamer/hhvm
<?php

$file = dirname(__FILE__) . '/src.gd2';
$im2 = imagecreatefromgd2($file);
echo 'test create from gd2: ';
echo imagecolorat($im2, 4, 4) == 0xffffff ? 'ok' : 'failed';
echo "\n";
$im3 = imagecreatefromgd2part($file, 4, 4, 2, 2);
echo 'test create from gd2 part: ';
echo imagecolorat($im2, 4, 4) == 0xffffff ? 'ok' : 'failed';
echo "\n";
コード例 #4
0
 public function createFrom(string $type, string $source, array $settings = NULL)
 {
     $type = strtolower($type);
     switch ($type) {
         case 'gd2':
             $return = imagecreatefromgd2($source);
             break;
         case 'gd':
             $return = imagecreatefromgd($source);
             break;
         case 'gif':
             $return = imagecreatefromgif($source);
             break;
         case 'jpeg':
             $return = imagecreatefromjpeg($source);
             break;
         case 'png':
             $return = imagecreatefrompng($source);
             break;
         case 'string':
             $return = imagecreatefromstring($source);
             break;
         case 'wbmp':
             $return = imagecreatefromwbmp($source);
             break;
         case 'webp':
             $return = imagecreatefromwebp($source);
             break;
         case 'xbm':
             $return = imagecreatefromxbm($source);
             break;
         case 'xpm':
             $return = imagecreatefromxpm($source);
             break;
         case 'gd2p':
             $return = imagecreatefromgd2part($source, isset($settings['x']) ? $settings['x'] : NULL, isset($settings['y']) ? $settings['y'] : NULL, isset($settings['width']) ? $settings['width'] : NULL, isset($settings['height']) ? $settings['height'] : NULL);
     }
     return $return;
 }
コード例 #5
0
 /**
  * Load Part Of gd canvas from file
  *
  * <b>Note :</b>
  * This method will not check if the coordinat is valid coordinate for the
  * resource and it won't check the Dimension either.
  *
  * @param string      $file
  * @param \Jaguar\Box $box
  *
  * @return \Jaguar\Format\Gd
  *
  * @throws \InvalidArgumentException
  * @throws \Jaguar\Exception\CanvasCreationException
  */
 public function partFromFile($file, Box $box)
 {
     $this->isValidFile($file);
     $this->assertGdFile($file);
     $x = $box->getX();
     $y = $box->getY();
     $width = $box->getWidth();
     $height = $box->getHeight();
     $result = @imagecreatefromgd2part($file, $x, $y, $width, $height);
     if (false == $result) {
         throw new CanvasCreationException(sprintf('Faild To Create The Part "%s" Of The Gd Canvas From The File "%s"', $file, (string) $box));
     }
     $this->setHandler($result);
     return $this;
 }
コード例 #6
0
ファイル: GD.php プロジェクト: Allopa/ZN-Framework-Starter
 public function createFrom($type = '', $source = '', $x = '', $y = '', $width = '', $height = '')
 {
     if (!is_string($type) || !is_string($source)) {
         return Error::set(lang('Error', 'stringParameter', '1.(type) & 2.(source)'));
     }
     $type = strtolower($type);
     switch ($type) {
         case 'gd2':
             $return = imagecreatefromgd2($source);
             break;
         case 'gd':
             $return = imagecreatefromgd($source);
             break;
         case 'gif':
             $return = imagecreatefromgif($source);
             break;
         case 'jpeg':
             $return = imagecreatefromjpeg($source);
             break;
         case 'png':
             $return = imagecreatefrompng($source);
             break;
         case 'string':
             $return = imagecreatefromstring($source);
             break;
         case 'wbmp':
             $return = imagecreatefromwbmp($source);
             break;
         case 'webp':
             $return = imagecreatefromwebp($source);
             break;
         case 'xbm':
             $return = imagecreatefromxbm($source);
             break;
         case 'xpm':
             $return = imagecreatefromxpm($source);
             break;
         case 'gd2p':
             $return = imagecreatefromgd2part($source, $x, $y, $width, $height);
     }
     return $return;
 }
コード例 #7
0
ファイル: image.php プロジェクト: juslee/e27
function showThumb($src, $thumbWidth, $thumbHeight, $dest = "")
{
    $info = pathinfo($src);
    // load image and get image size
    //$src = str_replace("%20", "", $src);
    //$src  = "http://google.com";
    //echo file_get_contents($src);
    //exit();
    if (strpos($src, "http://" . $_SERVER['HTTP_HOST'] . "/media/") === 0) {
        $p = urldecode($_GET['p']);
        $src = str_replace("http://" . $_SERVER['HTTP_HOST'] . "/media/", dirname(__FILE__) . "/", $p);
    }
    if ($_GET['showsrc']) {
        echo $src;
        exit;
    }
    $img = @imagecreatefromjpeg($src);
    if (!$img) {
        $img = @imagecreatefrompng($src);
    }
    if (!$img) {
        $img = @imagecreatefromgif($src);
    }
    if (!$img) {
        $img = @imagecreatefromwbmp($src);
    }
    if (!$img) {
        $img = @imagecreatefromgd2($src);
    }
    if (!$img) {
        $img = @imagecreatefromgd2part($src);
    }
    if (!$img) {
        $img = @imagecreatefromgd($src);
    }
    if (!$img) {
        $img = @imagecreatefromstring($src);
    }
    if (!$img) {
        $img = @imagecreatefromxbm($src);
    }
    if (!$img) {
        $img = @imagecreatefromxpm($src);
    }
    if (!$img) {
        return false;
    }
    $width = imagesx($img);
    $height = imagesy($img);
    $new_width = $width;
    $new_height = $height;
    // calculate thumbnail size
    if ($width > $height) {
        if ($thumbWidth < $width) {
            $new_width = $thumbWidth;
            $new_height = floor($height * ($thumbWidth / $width));
        }
    } else {
        if ($thumbHeight < $height) {
            $new_height = $thumbHeight;
            $new_width = floor($width * ($thumbHeight / $height));
        }
    }
    if ($_GET['square']) {
        if ($new_width > $new_height) {
            $side = $new_width;
        } else {
            $side = $new_height;
        }
        $tmp_img = imagecreatetruecolor($side, $side);
        $white = imagecolorallocate($tmp_img, 255, 255, 255);
        imagefill($tmp_img, 0, 0, $white);
        imagecopyresampled($tmp_img, $img, ($side - $new_width) / 2, ($side - $new_height) / 2, 0, 0, $new_width, $new_height, $width, $height);
    } else {
        // create a new temporary image
        $tmp_img = imagecreatetruecolor($new_width, $new_height);
        $white = imagecolorallocate($tmp_img, 255, 255, 255);
        imagefill($tmp_img, 0, 0, $white);
        // copy and resize old image into new image
        imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    }
    if (!trim($dest)) {
        imagepng($tmp_img, null, 0);
    } else {
        @imagepng($tmp_img, $dest, 0);
        imagepng($tmp_img, null, 0);
    }
    // save thumbnail into a file
}