当前位置: 首页>>代码示例>>PHP>>正文


PHP imagegd2函数代码示例

本文整理汇总了PHP中imagegd2函数的典型用法代码示例。如果您正苦于以下问题:PHP imagegd2函数的具体用法?PHP imagegd2怎么用?PHP imagegd2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imagegd2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: making

 public function making($dst_w, $dst_h)
 {
     $thumb_img = imagecreatetruecolor($dst_w, $dst_h);
     imagecopyresampled($thumb_img, $this->image, 0, 0, 0, 0, $dst_w, $dst_h, $this->width, $this->height);
     ob_start();
     switch ($this->_mimetype) {
         case "gd2":
             imagegd2($thumb_img, null, 100);
             break;
         case "gd":
             imagegd($thumb_img, null, 100);
             break;
         case "gif":
             imagegif($thumb_img, null, 100);
             break;
         case "jpeg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "jpg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "png":
             imagepng($thumb_img, null, 9);
             break;
         case "webp":
             imagewebp($thumb_img, null, 100);
             break;
         default:
             throw new \yii\base\NotSupportedException("Unsupport imageX method!");
             break;
     }
     imagedestroy($this->image);
     //destory origin
     return ob_get_clean();
     //返回二进制数据流
 }
开发者ID:gtyd,项目名称:jira,代码行数:36,代码来源:Stream.php

示例2: save

 /**
  * Saves the image to a file
  *
  * @param GDImage_Image $img
  * @param string $uri
  * @param integer $chunk_size
  * @param integer $type
  */
 function save($handle, $uri = null, $chunk_size = null, $type = null)
 {
     ob_start();
     imagegd2($handle, null, $chunk_size, $type);
     $imageBuffer = ob_get_contents();
     ob_end_clean();
     JFile::write($uri, $imageBuffer);
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:16,代码来源:GD2.php

示例3: cloneGdResource

 /**
  * Workarround method for cloning a GD2 image resource.
  *
  * @param resource $resource
  *
  * @return resource
  */
 private function cloneGdResource($resource)
 {
     ob_start();
     imagegd2($resource);
     $clone = imagecreatefromstring(ob_get_clean());
     // Only works for images with transparency if we set these
     imagealphablending($clone, false);
     imagesavealpha($clone, true);
     return $clone;
 }
开发者ID:ebeyrent,项目名称:gd-wrapper,代码行数:17,代码来源:AbstractResource.php

示例4: toBinaryData

 /**
  * Returns the binary data for the image.
  *
  * @return string
  * @author Oliver Lillie
  */
 public function toBinaryData()
 {
     $gd = $this->toGdImage();
     if ($gd !== false) {
         ob_start();
         imagegd2($gd);
         return ob_get_clean();
     }
     return false;
 }
开发者ID:kunitwru,项目名称:phpvideotoolkit-v2,代码行数:16,代码来源:Image.php

示例5: readFileOk

 /**
  * @test
  */
 public function readFileOk()
 {
     $file = ROOT . '/test/assets/images/file2.png';
     $resource = $this->reader->read($file);
     ob_start();
     imagegd2($resource->getRaw());
     $contents = md5(ob_get_clean());
     ob_start();
     $fromGd = imagecreatefrompng($file);
     imagegd2($fromGd);
     $expected = md5(ob_get_clean());
     $this->assertEquals($expected, $contents);
 }
开发者ID:ebeyrent,项目名称:gd-wrapper,代码行数:16,代码来源:PngReaderTest.php

示例6: compress

 /**
  * 按比例压缩图片
  * @param int $percent
  * @return string  二进制数据流
  */
 public function compress($percent)
 {
     $image = imagecreatefromstring($this->_StreamData);
     $width = imagesx($image);
     //原图width
     $height = imagesy($image);
     //原图height
     $t_w = $percent * $width;
     //缩略图width
     $t_h = $percent * $height;
     //缩略图height
     $thumb_img = imagecreatetruecolor($t_w, $t_h);
     imagecopyresampled($thumb_img, $image, 0, 0, 0, 0, $t_w, $t_h, $width, $height);
     ob_start();
     switch ($this->_mimetype) {
         case "gd2":
             imagegd2($thumb_img, null, 100);
             break;
         case "gd":
             imagegd($thumb_img, null, 100);
             break;
         case "gif":
             imagegif($thumb_img, null, 100);
             break;
         case "jpeg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "jpg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "png":
             imagepng($thumb_img, null, 100);
             break;
         default:
             throw new \yii\base\NotSupportedException("Unsupport imageX method!");
             break;
     }
     imagedestroy($image);
     //destory origin
     return ob_get_clean();
     //返回二进制数据流
 }
开发者ID:gtyd,项目名称:jira,代码行数:47,代码来源:ImageStreamHelper.php

示例7: set

 /** {@inheritdoc} */
 public function set($z, $x, $y, $img)
 {
     ob_start();
     imagegd2($img);
     $data = ob_get_clean();
     $z = (int) $z;
     $x = (int) $x;
     $y = (int) $y;
     $result = $this->get($z, $x, $y);
     if ($result) {
         $stmt = $this->db->prepare("UPDATE tiledata SET image = :image WHERE z = :z AND x = :x AND y = :y;");
     } else {
         $stmt = $this->db->prepare("INSERT INTO tiledata (z, x, y, image) VALUES(:z, :x, :y, :image);");
     }
     $stmt->bindValue('z', $x, \SQLITE3_INTEGER);
     $stmt->bindValue('x', $z, \SQLITE3_INTEGER);
     $stmt->bindValue('y', $y, \SQLITE3_INTEGER);
     $stmt->bindValue('image', $data, \SQLITE3_BLOB);
     $stmt->execute();
 }
开发者ID:nimetu,项目名称:ryzom_maps,代码行数:21,代码来源:SqlTileStorage.php

示例8: copyResampledPart

 /**
  * Neues Bild Stueckweise erstellen
  */
 private function copyResampledPart(&$image, &$newImage, $newImageInfo, $newWidth, $newHeight, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $bgColor = null)
 {
     // Breite und Hoehe angegeben?
     if ($newWidth <= 0 && $newHeight <= 0) {
         // Fehler
         return;
     }
     // temporaeres Verzeichnis vorhanden
     if (!empty($this->tempDir) && file_exists($this->tempDir)) {
         // Ja -> verwenden
         $tmpDir = $this->tempDir;
     } else {
         // Nein -> temporaeres Verzeichnis des Systems verwenden
         $tmpDir = sys_get_temp_dir();
     }
     // Maximial Breite der einzelnen Bereich ermitteln
     $partWidth = 50;
     $maxUsedMemory = $this->getMemoryLimit() - memory_get_usage();
     if ($maxUsedMemory > 0) {
         do {
             $partWidth = $newImageInfo['width'] = (int) ceil($newImageInfo['width'] / 2);
             $requiredMemory = $this->getRequiredMemory($newImageInfo);
         } while ($partWidth > 50 && $maxUsedMemory < $requiredMemory);
     }
     if ($partWidth < 50) {
         $partWidth = 50;
     }
     // Bild in einzelne Bereich zerlegen
     $partImages = array();
     $partX = 0;
     while ($partX < $newWidth) {
         $partImage = null;
         $success = $this->doCopyResampled($image, $partImage, $this->imageType, $partWidth, $newHeight, $dst_x - $partX, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $bgColor);
         if ($success && $partImage) {
             $temp_file = tempnam($tmpDir, 'part_img_');
             if (!imagegd2($partImage, $temp_file)) {
                 return false;
             }
             $partImages[] = array('x' => $partX, 'file' => $temp_file);
             imagedestroy($partImage);
             gc_collect_cycles();
         } else {
             return false;
         }
         $partX += $partWidth;
     }
     // Originalbild schliessen
     imagedestroy($image);
     gc_collect_cycles();
     $image = null;
     // neues Bild erstellen
     $newImage = imagecreatetruecolor($newWidth, $newHeight);
     if (!$newImage) {
         return false;
     }
     // Neues Bild aus den einzelne Bereich erstellen
     $first = true;
     foreach ($partImages as $nextPart) {
         $partImage = imagecreatefromgd2($nextPart['file']);
         unlink($nextPart['file']);
         if ($newImage && $partImage) {
             $this->doCopyResampled($partImage, $newImage, $this->imageType, $newWidth, $newHeight, $nextPart['x'], 0, 0, 0, $partWidth, $newHeight, $partWidth, $newHeight, $bgColor, $first);
         }
         if ($partImage) {
             imagedestroy($partImage);
         }
         $first = false;
     }
     // Status zurueckgeben
     return $newImage ? true : false;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:74,代码来源:Phpgd.php

示例9: saveToGD2

 public function saveToGD2($_filename)
 {
     if (file_exists($_filename)) {
         unlink($_filename);
     }
     $result = imagegd2($this->resource, $_filename);
     if ($result === false) {
         throw new \UnexpectedValueException("fail to save");
     }
 }
开发者ID:keradus,项目名称:graphics,代码行数:10,代码来源:Image.php

示例10: gdImageToBinaryData

 protected function gdImageToBinaryData($gdImage)
 {
     ob_start();
     imagegd2($gdImage);
     return ob_get_clean();
 }
开发者ID:nabeelio,项目名称:ffmpeg-php,代码行数:6,代码来源:FFmpegFrame.php

示例11: saveImage

 /**
  * Prints the Image
  * 
  * @param string $name
  * @param string $directory
  * @param string $imageType
  */
 private function saveImage($name, $directory, $imageType = 'png', $foreground = null)
 {
     switch ($imageType) {
         case 'jpg':
         case 'jpeg':
             imagejpeg($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gif':
             imagegif($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gd':
             imagegd($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gd2':
             imagegd2($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'webp':
             imagewebp($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'wbmp':
             imagewbmp($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType, $foreground);
             break;
         case 'xbm':
             imagexbm($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType, $foreground);
             break;
         case 'svg':
         default:
             imagepng($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
     }
     imagedestroy($this->imageProperties[0]);
 }
开发者ID:rajibmp,项目名称:imager,代码行数:38,代码来源:DrawImage.php

示例12: dirname

<?php

$cwd = dirname(__FILE__);
echo "JPEG to GD1 conversion: ";
echo imagegd(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "JPEG to GD2 conversion: ";
echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
echo "GD1 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed';
echo "\n";
echo "GD2 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
@unlink($cwd . "/test_gd1.jpeg");
@unlink($cwd . "/test_gd2.jpeg");
开发者ID:badlamer,项目名称:hhvm,代码行数:19,代码来源:jpg2gd.php

示例13: output

 function output($a_mime = 'image/png')
 {
     $mime = trim(strtolower($a_mime));
     if ($this->m_handle) {
         ob_start();
         switch ($mime) {
             case 'jpg':
             case 'jpeg':
             case 'image/jpeg':
                 imagejpeg($this->m_handle);
                 break;
             case 'png':
             case 'image/png':
                 imagepng($this->m_handle);
                 break;
             case 'gif':
             case 'image/gif':
                 imagegif($this->m_handle);
                 break;
             case 'gd':
             case 'image/gd':
                 imagegd($this->m_handle);
                 break;
             case 'gd2':
             case 'image/gd2':
                 imagegd2($this->m_handle);
                 break;
             case 'bmp':
             case 'wbmp':
             case 'image/bmp':
             case 'image/wbmp':
                 imagewbmp($this->m_handle);
                 break;
         }
         ZResponse::getInstance()->setContent(ob_get_contents());
         ob_end_clean();
     }
     ZResponse::getInstance()->setContentType($mime);
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:39,代码来源:image.php

示例14: dirname

<?php

$cwd = dirname(__FILE__);
echo "XPM to GD1 conversion: ";
echo imagegd(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "XPM to GD2 conversion: ";
echo imagegd2(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:xpm2gd.php

示例15: imagecreate

<?php

$image = imagecreate(1, 1);
// 1px image
$tempdir = sys_get_temp_dir() . '/php-gdtest';
if (!file_exists($tempdir) && !is_dir($tempdir)) {
    mkdir($tempdir, 0777, true);
}
$userinput = "1";
// from post or get data
$temp = $tempdir . "/test" . $userinput . ".tmp";
echo "\nimagegd2 TEST\n";
imagegd2($image, $temp);
var_dump(file_exists($tempdir . "/test1"));
var_dump(file_exists($tempdir . "/test1.tmp"));
foreach (glob($tempdir . "/test*") as $file) {
    unlink($file);
}
error_reporting(0);
$tempdir = sys_get_temp_dir() . '/php-gdtest';
foreach (glob($tempdir . "/test*") as $file) {
    unlink($file);
}
rmdir($tempdir);
开发者ID:badlamer,项目名称:hhvm,代码行数:24,代码来源:imagegd2_nullbyte_injection.php


注:本文中的imagegd2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。