本文整理汇总了PHP中imageGif函数的典型用法代码示例。如果您正苦于以下问题:PHP imageGif函数的具体用法?PHP imageGif怎么用?PHP imageGif使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageGif函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: save
/**
* 生成された画像を保存する
*
* @return boolean
* @access public
* @static
*/
function save()
{
//保存先のディレクトリが存在しているかチェック
$filePath = dirname($this->dstPath);
if (!file_exists($filePath)) {
mkdir($filePath);
}
if ($this->imageType == 'image/jpeg') {
return imageJpeg($this->dstImage, $this->dstPath, $this->quality);
} elseif ($this->imageType == 'image/gif') {
return imageGif($this->dstImage, $this->dstPath);
} elseif ($this->imageType == 'image/png') {
return imagePng($this->dstImage, $this->dstPath);
}
}
开发者ID:hamhei,项目名称:onatter,代码行数:22,代码来源:thumbmake.php
示例2: CreateGifThumbnail
public static function CreateGifThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
{
$srcImg = ImageCreateFromGif($imageDirectory . $imageName);
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
$ratio = $thumbWidth / $origWidth;
$thumbHeight = $origHeight * $ratio;
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, imagesx($srcImg), imagesy($srcImg));
imageGif($thumbImg, $thumbDirectory . "tn_" . $imageName);
}
开发者ID:brandfeverinc,项目名称:coke-cooler,代码行数:11,代码来源:Helpers.php
示例3: saveFile
public static function saveFile($image = null, $destFile = null, $saveType = self::SAVE_JPG)
{
switch ($saveType) {
case self::SAVE_GIF:
return @imageGif($image, $destFile);
case self::SAVE_JPG:
return @imageJpeg($image, $destFile, self::SAVE_QUALITY);
case self::SAVE_PNG:
return @imagePng($image, $destFile);
default:
return false;
}
}
开发者ID:yunsite,项目名称:hhzuitu,代码行数:13,代码来源:Image.class.php
示例4: AnimatedOut
function AnimatedOut()
{
for ($i = 0; $i < ANIM_FRAMES; $i++) {
$image = imageCreateTrueColor(imageSX($this->image), imageSY($this->image));
if (imageCopy($image, $this->image, 0, 0, 0, 0, imageSX($this->image), imageSY($this->image))) {
Captcha::DoNoise($image, 200, 0);
Ob_Start();
imageGif($image);
imageDestroy($image);
$f_arr[] = Ob_Get_Contents();
$d_arr[] = ANIM_DELAYS;
Ob_End_Clean();
}
}
$GIF = new GIFEncoder($f_arr, $d_arr, 0, 2, -1, -1, -1, 'C_MEMORY');
return $GIF->GetAnimation();
}
开发者ID:joly,项目名称:web2project,代码行数:17,代码来源:Captcha.class.php
示例5: createNewImage
private function createNewImage($newImg, $newName, $imgInfo)
{
switch ($imgInfo["type"]) {
case 1:
//gif
$result = imageGif($newImg, $this->path . $newName);
break;
case 2:
//jpg
$result = imageJPEG($newImg, $this->path . $newName);
break;
case 3:
//png
$return = imagepng($newImg, $this->path . $newName);
break;
}
imagedestroy($newImg);
return $newName;
}
开发者ID:Rockroc,项目名称:PHP,代码行数:19,代码来源:image.class.php
示例6: resizeImage
function resizeImage($file, $max_x, $max_y, $forcePng = false)
{
if ($max_x <= 0 || $max_y <= 0) {
$max_x = 5;
$max_y = 5;
}
$src = BASEDIR . '/avatars/' . $file;
list($width, $height, $type) = getImageSize($src);
$scale = min($max_x / $width, $max_y / $height);
$newWidth = $width * $scale;
$newHeight = $height * $scale;
$img = imagecreatefromstring(file_get_contents($src));
$black = imagecolorallocate($img, 0, 0, 0);
$resizedImage = imageCreateTrueColor($newWidth, $newHeight);
imagecolortransparent($resizedImage, $black);
imageCopyResampled($resizedImage, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
imageDestroy($img);
unlink($src);
if (!$forcePng) {
switch ($type) {
case IMAGETYPE_JPEG:
imageJpeg($resizedImage, BASEDIR . '/avatars/' . $file);
break;
case IMAGETYPE_GIF:
imageGif($resizedImage, BASEDIR . '/avatars/' . $file);
break;
case IMAGETYPE_PNG:
imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
break;
default:
imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
break;
}
} else {
imagePng($resizedImage, BASEDIR . '/avatars/' . $file . '.png');
}
return;
}
开发者ID:kandran,项目名称:flyspray,代码行数:38,代码来源:modify.inc.php
示例7: save
function save($filename, $type = 'png', $quality = 100)
{
$this->_build();
$this->_build_border();
switch ($type) {
case 'gif':
$ret = imageGif($this->_dest_image, $filename);
break;
case 'jpg':
case 'jpeg':
$ret = imageJpeg($this->_dest_image, $filename, $quality);
break;
case 'png':
$ret = imagePng($this->_dest_image, $filename);
break;
default:
$this->_error('Save: Invalid Format');
break;
}
if (!$ret) {
$this->_error('Save: Unable to save');
}
}
开发者ID:mbassan,项目名称:backstage2,代码行数:23,代码来源:Image.php
示例8: substr
$alphabet = '1234567890abcdefghijkmnpqrstuvwxyz';
$string = substr(str_shuffle(str_repeat($alphabet, $length)), 0, $length);
//���������� �����
$img = imagecreate(140, 50);
//������� ��������
if ($color == "red") {
$color = imagecolorAllocate($img, 249, 183, 169);
$border_color = imagecolorAllocate($img, 212, 12, 12);
} else {
$color = imagecolorAllocate($img, 217, 239, 185);
$border_color = imagecolorAllocate($img, 160, 214, 81);
}
$text_color = imagecolorAllocate($img, 102, 102, 102);
$�� = (imageSX($img) - 1 * strlen($string)) / 2;
imagettftext($img, 23, -3, 10, 30, $text_color, 'font.TTF', $string);
imageGif($img, "img/number.gif");
imageDestroy($img);
$_SESSION["capcha"] = $string;
?>
<div class="loginform" <?php
if ($_SESSION['try'] > $num_for_lock) {
echo 'style="background:url(../img/lock.png) no-repeat 60% 30%;"';
}
?>
>
<form method="post" action="index.php" >
<fieldset >
<p>
<label for="login" class="top">����:</label><br />
<input type="text" name="login" id="login" tabindex="1" class="field" value="<?php
echo $_POST['login'];
开发者ID:AlexSlovinskiy,项目名称:magistr.zu.edu.ua,代码行数:31,代码来源:LoginForm.php
示例9: session_start
<?php
session_start();
$alpha = "0123456789";
$secret = "";
$old_user_id;
for ($i = 0; $i < 5; $i++) {
$secret .= $alpha[rand(0, strlen($alpha) - 1)];
}
$_SESSION['secret'] = $secret;
$im = imagecreate(80, 31);
imageColorAllocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 10, 10, $secret, $textcolor);
imageGif($im);
header("Content-Type: image/gif");
开发者ID:viljinsky,项目名称:auth5,代码行数:16,代码来源:captcha.php
示例10: imageResize
//.........这里部分代码省略.........
if ($params["WIDTH"] == 55 && $params["HEIGHT"] == 45)
{
imageAlphaBlending($im, true);
$waterMark = ImageCreateFromPng($_SERVER["DOCUMENT_ROOT"] . "/img/video.png");
imageCopyResampled($im, $waterMark, 0, 0, 0, 0, $params["WIDTH"], $params["HEIGHT"], $params["WIDTH"], $params["HEIGHT"]);
}
break;
case 'width' :
$factor = $i[1] / $i[0]; // определяем пропорцию height / width
if ($factor > 1.35)
{
$pn["WIDTH"] = $params["WIDTH"];
$scale_factor = $i[0] / $pn["WIDTH"]; // коэфффициент масштабирования
$pn["HEIGHT"] = ceil($i[1] / $scale_factor);
$x = 0;
$y = 0;
if (($params["HEIGHT"] / $pn["HEIGHT"]) < 0.6)
{
//echo 100 / ($pn["HEIGHT"] * 100) / ($params["HEIGHT"] *1.5);
$pn["HEIGHT"] = (100 / (($pn["HEIGHT"] * 100) / ($params["HEIGHT"] * 1.3))) * $pn["HEIGHT"];
$newKoef = $i[1] / $pn["HEIGHT"];
$pn["WIDTH"] = $i[0] / $newKoef;
$x = ($params["WIDTH"] - $pn["WIDTH"]) / 2;
//$y = ($params["HEIGHT"] - $pn["HEIGHT"]) / 2;
}
imageCopyResampled($im, $i0, $x, $y, 0, 0, $pn["WIDTH"], $pn["HEIGHT"], $i[0], $i[1]);
}
else
{
if (($i [0] < $params["WIDTH"]) && ($i [1] < $params["HEIGHT"]))
{
$k_x = 1;
$k_y = 1;
}
else
{
$k_x = $i [0] / $params["WIDTH"];
$k_y = $i [1] / $params["HEIGHT"];
}
if ($k_x < $k_y)
$k = $k_y;
else
$k = $k_x;
$pn["WIDTH"] = $i [0] / $k;
$pn["HEIGHT"] = $i [1] / $k;
$x = ($params["WIDTH"] - $pn["WIDTH"]) / 2;
$y = ($params["HEIGHT"] - $pn["HEIGHT"]) / 2;
imageCopyResampled($im, $i0, $x, $y, 0, 0, $params["MODE"], $pn["HEIGHT"], $i[0], $i[1]);
}
break;
default : imageCopyResampled($im, $i0, 0, 0, 0, 0, $params["WIDTH"], $params["HEIGHT"], $i[0], $i[1]);
break;
}
if ($params["HIQUALITY"])
{
$sharpenMatrix = array
(
array(-1.2, -1, -1.2),
array(-1, 20, -1),
array(-1.2, -1, -1.2)
);
// calculate the sharpen divisor
$divisor = array_sum(array_map('array_sum', $sharpenMatrix));
$offset = 0;
// apply the matrix
imageconvolution($im, $sharpenMatrix, $divisor, $offset);
}
switch (strtolower($imageType))
{
case 'gif' :imageSaveAlpha($im, true);
@imageGif($im, CHACHE_IMG_PATH . $pathToFile);
break;
case 'jpg' : case 'jpeg' : @imageJpeg($im, CHACHE_IMG_PATH . $pathToFile, $params["QUALITY"]);
break;
case 'png' : imageSaveAlpha($im, true);
@imagePng($im, CHACHE_IMG_PATH . $pathToFile);
break;
}
}
else
{
copy($pathToOriginalFile, CHACHE_IMG_PATH . $pathToFile);
}
return RETURN_IMG_PATH . $pathToFile;
}
开发者ID:ASDAFF,项目名称:alba,代码行数:101,代码来源:tools_new.php
示例11: write
/**
* Write a gif image to file
* @param File file of the image
* @param resource internal PHP image resource
*/
public function write(File $file, $resource)
{
$this->checkIfWriteIsPossible($file, $resource, 'gif');
imageGif($resource, $file->getAbsolutePath());
}
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:10,代码来源:GifImageIO.php
示例12: resizeImage
/**
* Generate images of alternate sizes.
*/
function resizeImage($cnvrt_arry)
{
global $platform, $imgs, $cnvrt_path, $reqd_image, $convert_writable, $convert_magick, $convert_GD, $convert_cmd, $cnvrt_alt, $cnvrt_mesgs, $compat_quote;
if (empty($imgs) || $convert_writable == FALSE) {
return;
}
if ($convert_GD == TRUE && !($gd_version = gdVersion())) {
return;
}
if ($cnvrt_alt['no_prof'] == TRUE) {
$strip_prof = ' +profile "*"';
} else {
$strip_prof = '';
}
if ($cnvrt_alt['mesg_on'] == TRUE) {
$str = '';
}
foreach ($imgs as $img_file) {
if ($cnvrt_alt['indiv'] == TRUE && $img_file != $reqd_image['file']) {
continue;
}
$orig_img = $reqd_image['pwd'] . '/' . $img_file;
$cnvrtd_img = $cnvrt_path . '/' . $cnvrt_arry['prefix'] . $img_file;
if (!is_file($cnvrtd_img)) {
$img_size = GetImageSize($orig_img);
$height = $img_size[1];
$width = $img_size[0];
$area = $height * $width;
$maxarea = $cnvrt_arry['maxwid'] * $cnvrt_arry['maxwid'] * 0.9;
$maxheight = $cnvrt_arry['maxwid'] * 0.75 + 1;
if ($area > $maxarea || $width > $cnvrt_arry['maxwid'] || $height > $maxheight) {
if ($width / $cnvrt_arry['maxwid'] >= $height / $maxheight) {
$dim = 'W';
}
if ($height / $maxheight >= $width / $cnvrt_arry['maxwid']) {
$dim = 'H';
}
if ($dim == 'W') {
$cnvt_percent = round(0.9375 * $cnvrt_arry['maxwid'] / $width * 100, 2);
}
if ($dim == 'H') {
$cnvt_percent = round(0.75 * $cnvrt_arry['maxwid'] / $height * 100, 2);
}
// convert it
if ($convert_magick == TRUE) {
// Image Magick image conversion
if ($platform == 'Win32' && $compat_quote == TRUE) {
$winquote = '"';
} else {
$winquote = '';
}
exec($winquote . $convert_cmd . ' -geometry ' . $cnvt_percent . '%' . ' -quality ' . $cnvrt_arry['qual'] . ' -sharpen ' . $cnvrt_arry['sharpen'] . $strip_prof . ' "' . $orig_img . '"' . ' "' . $cnvrtd_img . '"' . $winquote);
$using = $cnvrt_mesgs['using IM'];
} elseif ($convert_GD == TRUE) {
// GD image conversion
if (eregi('\\.jpg$|\\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) {
$src_img = imageCreateFromJpeg($orig_img);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) {
$src_img = imageCreateFromPng($orig_img);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) {
$src_img = imageCreateFromGif($orig_img);
} else {
continue;
}
$src_width = imageSx($src_img);
$src_height = imageSy($src_img);
$dest_width = $src_width * ($cnvt_percent / 100);
$dest_height = $src_height * ($cnvt_percent / 100);
if ($gd_version >= 2) {
$dst_img = imageCreateTruecolor($dest_width, $dest_height);
imageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
} else {
$dst_img = imageCreate($dest_width, $dest_height);
imageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
}
imageDestroy($src_img);
if (eregi('\\.jpg$|\\.jpeg$/i', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) {
imageJpeg($dst_img, $cnvrtd_img, $cnvrt_arry['qual']);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) {
imagePng($dst_img, $cnvrtd_img);
} elseif (eregi('\\.gif$/i', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) {
imageGif($dst_img, $cnvrtd_img);
}
imageDestroy($dst_img);
$using = $cnvrt_mesgs['using GD'] . $gd_version;
}
if ($cnvrt_alt['mesg_on'] == TRUE && is_file($cnvrtd_img)) {
$str .= " <small>\n" . ' ' . $cnvrt_mesgs['generated'] . $cnvrt_arry['txt'] . $cnvrt_mesgs['converted'] . $cnvrt_mesgs['image_for'] . $img_file . $using . ".\n" . " </small>\n <br />\n";
}
}
}
}
if (isset($str)) {
return $str;
}
}
开发者ID:kleopatra999,项目名称:PHPhoto,代码行数:99,代码来源:index.php
示例13: getTemporaryImageWithText
/**
* Creates error image based on gfx/notfound_thumb.png
* Requires GD lib enabled, otherwise it will exit with the three
* textstrings outputted as text. Outputs the image stream to browser and exits!
*
* @param string $filename Name of the file
* @param string $textline1 Text line 1
* @param string $textline2 Text line 2
* @param string $textline3 Text line 3
* @return void
* @throws \RuntimeException
*
* @internal Don't use this method from outside the LocalImageProcessor!
*/
public function getTemporaryImageWithText($filename, $textline1, $textline2, $textline3)
{
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
throw new \RuntimeException('TYPO3 Fatal Error: No gdlib. ' . $textline1 . ' ' . $textline2 . ' ' . $textline3, 1270853952);
}
// Creates the basis for the error image
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
$im = imagecreatefrompng(PATH_typo3 . 'gfx/notfound_thumb.png');
} else {
$im = imagecreatefromgif(PATH_typo3 . 'gfx/notfound_thumb.gif');
}
// Sets background color and print color.
$white = imageColorAllocate($im, 255, 255, 255);
$black = imageColorAllocate($im, 0, 0, 0);
// Prints the text strings with the build-in font functions of GD
$x = 0;
$font = 0;
if ($textline1) {
imagefilledrectangle($im, $x, 9, 56, 16, $white);
imageString($im, $font, $x, 9, $textline1, $black);
}
if ($textline2) {
imagefilledrectangle($im, $x, 19, 56, 26, $white);
imageString($im, $font, $x, 19, $textline2, $black);
}
if ($textline3) {
imagefilledrectangle($im, $x, 29, 56, 36, $white);
imageString($im, $font, $x, 29, substr($textline3, -14), $black);
}
// Outputting the image stream and exit
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
imagePng($im, $filename);
} else {
imageGif($im, $filename);
}
}
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:50,代码来源:LocalImageProcessor.php
示例14: image_constrain_gd
//.........这里部分代码省略.........
// Нет - просто скопируем файл
if (!copy($src_file, $dst_file)) {
return false;
}
return true;
}
// Размеры превью при пропорциональном уменьшении
@(list($dst_w, $dst_h) = $this->calc_contrain_size($src_w, $src_h, $max_w, $max_h));
// Читаем изображение
switch ($src_type) {
case 'image/jpeg':
$src_img = imageCreateFromJpeg($src_file);
break;
case 'image/gif':
$src_img = imageCreateFromGif($src_file);
break;
case 'image/png':
$src_img = imageCreateFromPng($src_file);
imagealphablending($src_img, true);
break;
default:
return false;
}
if (empty($src_img)) {
return false;
}
$src_colors = imagecolorstotal($src_img);
// create destination image (indexed, if possible)
if ($src_colors > 0 && $src_colors <= 256) {
$dst_img = imagecreate($dst_w, $dst_h);
} else {
$dst_img = imagecreatetruecolor($dst_w, $dst_h);
}
if (empty($dst_img)) {
return false;
}
$transparent_index = imagecolortransparent($src_img);
if ($transparent_index >= 0 && $transparent_index <= 128) {
$t_c = imagecolorsforindex($src_img, $transparent_index);
$transparent_index = imagecolorallocate($dst_img, $t_c['red'], $t_c['green'], $t_c['blue']);
if ($transparent_index === false) {
return false;
}
if (!imagefill($dst_img, 0, 0, $transparent_index)) {
return false;
}
imagecolortransparent($dst_img, $transparent_index);
} elseif ($src_type === 'image/png') {
if (!imagealphablending($dst_img, false)) {
return false;
}
$transparency = imagecolorallocatealpha($dst_img, 0, 0, 0, 127);
if (false === $transparency) {
return false;
}
if (!imagefill($dst_img, 0, 0, $transparency)) {
return false;
}
if (!imagesavealpha($dst_img, true)) {
return false;
}
}
// resample the image with new sizes
if (!imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h)) {
return false;
}
// Watermark
if (!empty($watermark) && is_readable($watermark)) {
$overlay = imagecreatefrompng($watermark);
// Get the size of overlay
$owidth = imagesx($overlay);
$oheight = imagesy($overlay);
$watermark_x = min(($dst_w - $owidth) * $watermark_offet_x / 100, $dst_w);
$watermark_y = min(($dst_h - $oheight) * $watermark_offet_y / 100, $dst_h);
imagecopy($dst_img, $overlay, $watermark_x, $watermark_y, 0, 0, $owidth, $oheight);
//imagecopymerge($dst_img, $overlay, $watermark_x, $watermark_y, 0, 0, $owidth, $oheight, $watermark_opacity*100);
}
// recalculate quality value for png image
if ('image/png' === $src_type) {
$quality = round($quality / 100 * 10);
if ($quality < 1) {
$quality = 1;
} elseif ($quality > 10) {
$quality = 10;
}
$quality = 10 - $quality;
}
// Сохраняем изображение
switch ($src_type) {
case 'image/jpeg':
return imageJpeg($dst_img, $dst_file, $quality);
case 'image/gif':
return imageGif($dst_img, $dst_file, $quality);
case 'image/png':
imagesavealpha($dst_img, true);
return imagePng($dst_img, $dst_file, $quality);
default:
return false;
}
}
开发者ID:dimadmb,项目名称:100shub,代码行数:101,代码来源:Image.php
示例15: getTemporaryImageWithText
/**
* Creates error image based on gfx/notfound_thumb.png
* Requires GD lib enabled, otherwise it will exit with the three
* textstrings outputted as text. Outputs the image stream to browser and exits!
*
* @param string $filename Name of the file
* @param string $textline1 Text line 1
* @param string $textline2 Text line 2
* @param string $textline3 Text line 3
* @return void
* @throws \RuntimeException
*/
public function getTemporaryImageWithText($filename, $textline1, $textline2, $textline3)
{
if (empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])) {
throw new \RuntimeException('TYPO3 Fatal Error: No gdlib. ' . $textline1 . ' ' . $textline2 . ' ' . $textline3, 1270853952);
}
// Creates the basis for the error image
$basePath = ExtensionManagementUtility::extPath('core') . 'Resources/Public/Images/';
if (!empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'])) {
$im = imagecreatefrompng($basePath . 'NotFound.png');
} else {
$im = imagecreatefromgif($basePath . 'NotFound.gif');
}
// Sets background color and print color.
$white = imageColorAllocate($im, 255, 255, 255);
$black = imageColorAllocate($im, 0, 0, 0);
// Prints the text strings with the build-in font functions of GD
$x = 0;
$font = 0;
if ($textline1) {
imagefilledrectangle($im, $x, 9, 56, 16, $white);
imageString($im, $font, $x, 9, $textline1, $black);
}
if ($textline2) {
imagefilledrectangle($im, $x, 19, 56, 26, $white);
imageString($im, $font, $x, 19, $textline2, $black);
}
if ($textline3) {
imagefilledrectangle($im, $x, 29, 56, 36, $white);
imageString($im, $font, $x, 29, substr($textline3, -14), $black);
}
// Outputting the image stream and exit
if (!empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'])) {
imagePng($im, $filename);
} else {
imageGif($im, $filename);
}
}
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:49,代码来源:GraphicalFunctions.php
示例16: dirname
<?php
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/menu.class.php';
$img = imageCreateFromGif(dirname(__FILE__) . '/gfx/menu/menu_orig.gif');
if (isset($_GET['color']) && strlen($_GET['color']) === 6) {
$color = Tools::getValue('color');
$light = -150;
if (isset($_GET['light']) && ((int) $_GET['light'] >= 0 && (int) $_GET['light'] <= 200)) {
$light = (int) $_GET['light'] + $light;
} else {
$light += 100;
}
Menu::colorize($img, $color, $light);
}
if (isset($_GET['preview'])) {
header('Content-type: image/gif');
imageGif($img);
}
imagedestroy($img);
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:21,代码来源:colorize.php
示例17: showCartoonfy
function showCartoonfy($p_ext, $p_dis)
{
switch (strtolower($p_ext)) {
case "jpg":
header('Content-type:image/' . strtolower($p_ext));
if ($p_dis) {
header('Content-disposition:attachment;filename=' . time() . '.' . strtolower($p_ext));
}
imageJpeg($this->i1);
break;
case "jpeg":
header('Content-type:image/' . strtolower($p_ext));
if ($p_dis) {
header('Content-disposition:attachment;filename=' . time() . '.' . strtolower($p_ext));
}
imageJpeg($this->i1);
break;
case "gif":
header('Content-type:image/' . strtolower($p_ext));
if ($p_dis) {
header('Content-disposition:attachment;filename=' . time() . '.' . strtolower($p_ext));
}
imageGif($this->i1);
break;
case "png":
header('Content-type:image/' . strtolower($p_ext));
if ($p_dis) {
header('Content-disposition:attachment;filename=' . time() . '.' . strtolower($p_ext));
}
imagePng($this->i1);
break;
default:
print "<b>" . $p_ext . "</b> is not supported image format!";
exit;
}
imageDestroy($this->i1);
}
开发者ID:BGCX067,项目名称:facebookpiccartoonizer-svn-to-git,代码行数:37,代码来源:Cartoonfy.class.php
示例18: imageColorAllocate
/* Подготовка к работе */
//imageAntiAlias($i, true);
/*
$red = imageColorAllocate($i, 255, 0, 0);
$white = imageColorAllocate($i, 0xFF, 0xFF, 0xFF);
$black = imageColorAllocate($i, 0, 0, 0);
$green = imageColorAllocate($i, 0, 255, 0);
$blue = imageColorAllocate($i, 0, 0, 255);
$grey = imageColorAllocate($i, 192, 192, 192);
*/
//imageFill($i, 0, 0, $grey);
/* Рисуем примитивы */
//imageSetPixel($i, 10, 10, $black);
//imageLine($i, 20, 20, 80, 280, $red);
//imageRectangle($i, 20, 20, 80, 280, $blue);
//$points = array(0, 0, 100, 200, 300, 200);
//imagePolygon($i, $points, 3, $green);
//imageEllipse($i, 200, 150, 300, 200, $red);
//imageArc($i, 200, 150, 300, 200, 0, 40, $black);
//imageFilledArc($i, 200, 150, 300, 200, 0, 40, $red, IMG_ARC_PIE);
/* Рисуем текст */
//imageString($i, 5, 150, 200, 'PHP5', $black);
//imageChar($i, 3, 20, 20, 'PHP5', $blue);
//imageTtfText($i, 30, 10, 300, 150, $green,'arial.ttf', 'PHP5');
/* Отдаем изображение */
header("Content-type: image/gif");
imageGif($i);
//header("Content-type: image/png");
//imagePng($i);
//header("Content-type: image/jpg");
//imageJpeg($i);
开发者ID:rasfur,项目名称:php3,代码行数:31,代码来源:image_create.php
示例19: resize
/**
* This function resizes given image, if it has bigger dimensions, than we need and saves it (also makes chmod 0777 on the file) ...
* It uses GD or ImageMagick, setting is available to change in CL's config file.
*
* @param string $inputFileName the input file to work with
* @param string $outputFileName the file to write into the final (resized) image
* @param integer $maxNewWidth maximal width of image
* @param integer $maxNewHeight maximal height of image
* @return bool TRUE, if everything was successful (resize and chmod), else FALSE
*/
function resize($inputFileName, $outputFileName, $maxNewWidth, $maxNewHeight)
{
$imageInfo = getimagesize($inputFileName);
$fileType = $imageInfo['mime'];
$extension = strtolower(str_replace('.', '', substr($outputFileName, -4)));
$originalWidth = $imageInfo[0];
$originalHeight = $imageInfo[1];
if ($originalWidth > $maxNewWidth or $originalHeight > $maxNewHeight) {
$newWidth = $maxNewWidth;
$newHeight = $originalHeight / ($originalWidth / $maxNewWidth);
if ($newHeight > $maxNewHeight) {
$newHeight = $maxNewHeight;
$newWidth = $originalWidth / ($originalHeight / $maxNewHeight);
}
$newWidth = ceil($newWidth);
$newHeight = ceil($newHeight);
} else {
$newWidth = $originalWidth;
$newHeight = $originalHeight;
}
$ok = FALSE;
if (CL::getConf('CL_Images/engine') == 'imagick-cli') {
exec("convert -thumbnail " . $newWidth . "x" . $newHeight . " " . $inputFileName . " " . $outputFileName);
$ok = TRUE;
} elseif (CL::getConf('CL_Images/engine') == 'imagick-php') {
$image = new Imagick($inputFileName);
$image->thumbnailImage($newWidth, $newHeight);
$ok = (bool) $image->writeImage($outputFileName);
$image->clear();
$image->destroy();
} else {
$out = imageCreateTrueColor($newWidth, $newHeight);
switch (strtolower($fileType)) {
case 'image/jpeg':
$source = imageCreateFromJpeg($inputFileName);
break;
case 'image/png':
$source = imageCreateFromPng($inputFileName);
break;
case 'image/gif':
$source = imageCreateFromGif($inputFileName);
break;
default:
break;
}
imageCopyResized($out, $source, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
switch (strtolower($extension)) {
case 'jpg':
case 'jpeg':
if (imageJpeg($out, $outputFileName)) {
$ok = TRUE;
}
break;
case 'png':
if (imagePng($out, $outputFileName)) {
$ok = TRUE;
}
break;
case 'gif':
if (imageGif($out, $outputFileName)) {
$ok = TRUE;
}
break;
default:
break;
}
imageDestroy($out);
imageDestroy($source);
}
if ($ok and chmod($outputFileName, 0777)) {
return TRUE;
} else {
return FALSE;
}
}
开发者ID:renekliment,项目名称:CLE,代码行数:85,代码来源:class.cl.images.php
示例20: ImageWrite
/**
* Writes the input GDlib image pointer to file
*
* @param pointer The GDlib image resource pointer
* @param string The filename to write to
* @param integer The image quality (for JPEGs)
* @return boolean The output of either imageGif, imagePng or imageJpeg based on the filename to write
* @see maskImageOntoImage(), scale(), output()
*/
function ImageWrite($destImg, $theImage, $quality = 0)
{
imageinterlace($destImg, 0);
$ext = strtolower(substr($theImage, strrpos($theImage, '.') + 1));
$result = FALSE;
switch ($ext) {
case 'jpg':
case 'jpeg':
if (function_exists('imageJpeg')) {
if ($quality == 0) {
$quality = $this->jpegQuality;
}
$result = imageJpeg($destImg, $theImage, $quality);
}
break;
case 'gif':
if (function_exists('imageGif')) {
imagetruecolortopalette($destImg, TRUE, 256);
$result = imageGif($destImg, $theImage);
}
break;
case 'png':
if (function_exists('imagePng')) {
$result = ImagePng($destImg, $theImage);
}
break;
}
if ($result) {
t3lib_div::fixPermissions($theImage);
}
return $result;
}
开发者ID:NaveedWebdeveloper,项目名称:Test,代码行数:41,代码来源:class.t3lib_stdgraphic.php
注:本文中的imageGif函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论