• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagegd2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: saveGD

 /**
  * save gd resource to the given dest in (.gd2) extension
  * @param string $dest the dest path ex:('images/preview/')
  * @param resource $resource gd resource
  * @param string $name the file name
  * @return boolean true on success false otherwise
  */
 public static function saveGD($dest, $resource, $name)
 {
     if (@get_resource_type($resource) == TIP_RT) {
         if (!@is_dir($dest)) {
             self::logger("saveGD", "Dest Directory IS Not Exist ({$dest})");
         }
         $dest = $dest . $name . '.gd2';
         $result = @imagegd2($resource, $dest, null, IMG_GD2_COMPRESSED);
         if (!$result) {
             self::logger("saveGD", "Unable To Save GD Resource Into ({$dest})");
         }
         return $result;
     }
     self::logger("saveGD", " Not A GD Resource");
     return false;
 }
开发者ID:OccultScripto,项目名称:rogentos-www,代码行数:23,代码来源:tulipIP.php


示例17: resize


//.........这里部分代码省略.........
                             return false;
                         }
                     } else {
                         // image increased so as to completely fill the target area, and then cut
                         $ratio = 1;
                         if ($h_dst > $w_dst) {
                             $ratio = round($h_dst / $h_src, 4);
                         }
                         if ($h_dst < $w_dst) {
                             $ratio = round($w_dst / $w_src, 4);
                         }
                         $new_h = round($h_src * $ratio);
                         $new_w = round($w_src * $ratio);
                         $this->logInfo("Resize crop/enlarge ({$ratio})", array($w_src, $h_src, $new_w, $new_h));
                         if ($this->_prepareDstImage($new_w, $new_h)) {
                             imagecopyresampled($this->dst_image, $this->src_image, 0, 0, 0, 0, $new_w, $new_h, $w_src, $h_src);
                             $this->logInfo('Resize crop/enlarge OK');
                         } else {
                             $this->logInfo('Resize crop/enlarge error');
                             $this->setError('Resize&crop&enlarge error');
                             return false;
                         }
                         // calculations and cut image
                         if ($w_src > $w_dst or $h_src > $h_dst) {
                             $centerSrcW = round($new_w / 2, 1);
                             $centerSrcH = round($new_h / 2, 1);
                             if ($new_h > $h_dst) {
                                 $src_y = floor($centerSrcH - $centerDstH);
                                 $new_h = $h_dst;
                             }
                             if ($new_w > $w_dst) {
                                 $src_x = floor($centerSrcW - $centerDstW);
                                 $new_w = $w_dst;
                             }
                             imagedestroy($this->src_image);
                             $this->src_image = $this->dst_image;
                             $this->logInfo('Resize crop/enlarge/crop');
                             if ($this->_prepareDstImage($new_w, $new_h)) {
                                 imagecopy($this->dst_image, $this->src_image, 0, 0, $src_x, $src_y, $new_w, $new_h);
                                 $this->logInfo('Resize crop/enlarge/crop OK');
                             } else {
                                 $this->logInfo('Resize crop/enlarge/crop error');
                                 return false;
                             }
                         }
                     }
                 }
                 break;
             case self::RESIZE_METHOD_STRETCH:
                 $this->logInfo('Resize stretch');
                 if (!$enlarge and $w_src <= $w_dst and $h_src <= $h_dst) {
                     $result = copy($this->_oldfileAddr, $this->_newFileAddr);
                     return $result;
                 } else {
                     $new_h = $h_dst;
                     $new_w = $w_dst;
                 }
                 if ($this->_prepareDstImage($new_w, $new_h)) {
                     imagecopyresampled($this->dst_image, $this->src_image, 0, 0, 0, 0, $new_w, $new_h, $w_src, $h_src);
                     $this->logInfo('Resize stretch OK');
                 } else {
                     $this->logInfo('Resize stretch error');
                     $this->setError('Resize&stretch error');
                     return false;
                 }
                 break;
         }
     }
     if (!empty($this->_preset['water-image']) || !empty($this->_preset['water-text'])) {
         $this->logInfo('Watermarking');
         $this->_addWatermark();
     }
     $this->logInfo('Saving as ' . $this->_fileExtension);
     imagesavealpha($this->dst_image, true);
     switch ($this->_fileExtension) {
         case 'jpeg':
         case 'jpe':
         case 'jpg':
             $return = @imagejpeg($this->dst_image, $this->_newFileAddr, 100);
             break;
         case 'png':
             $return = @imagepng($this->dst_image, $this->_newFileAddr);
             break;
         case 'gif':
             $return = @imagegif($this->dst_image, $this->_newFileAddr);
             break;
         case 'gd':
             $return = @imagegd2($this->dst_image, $this->_newFileAddr, IMG_GD2_COMPRESSED);
             break;
         default:
             $this->setError('Unsupported media type of target file: ' . $this->_fileExtension);
             return false;
     }
     imagedestroy($this->src_image);
     $this->logInfo('Resize finished');
     if (!$return) {
         $this->setError('Result save error');
     }
     return $return;
 }
开发者ID:ValenokPC,项目名称:tabernacms,代码行数:101,代码来源:class.gd_image.php


示例18: save

 public function save($handle, $uri = null, $chunk_size = null, $type = null)
 {
     return imagegd2($handle, $uri, $chunk_size, $type);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:4,代码来源:GD2.php


示例19: dirname

<?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);
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:bug38212.php


示例20: dump

 public function dump()
 {
     ob_start();
     @imagegd2($this->raw);
     return ob_get_clean();
 }
开发者ID:LupusMichaelis,项目名称:horn,代码行数:6,代码来源:image.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagegif函数代码示例发布时间:2022-05-15
下一篇:
PHP imagegd函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap