本文整理汇总了PHP中imagePng函数的典型用法代码示例。如果您正苦于以下问题:PHP imagePng函数的具体用法?PHP imagePng怎么用?PHP imagePng使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagePng函数的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: image_createThumb
function image_createThumb($src, $dest, $maxWidth, $maxHeight, $quality = 75)
{
if (file_exists($src) && isset($dest)) {
// path info
$destInfo = pathInfo($dest);
// image src size
$srcSize = getImageSize($src);
// image dest size $destSize[0] = width, $destSize[1] = height
$srcRatio = $srcSize[0] / $srcSize[1];
// width/height ratio
$destRatio = $maxWidth / $maxHeight;
if ($destRatio > $srcRatio) {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight * $srcRatio;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth / $srcRatio;
}
// path rectification
if ($destInfo['extension'] == "gif") {
$dest = substr_replace($dest, 'jpg', -3);
}
// true color image, with anti-aliasing
$destImage = imageCreateTrueColor($destSize[0], $destSize[1]);
// imageAntiAlias($destImage,true);
// src image
switch ($srcSize[2]) {
case 1:
//GIF
$srcImage = imageCreateFromGif($src);
break;
case 2:
//JPEG
$srcImage = imageCreateFromJpeg($src);
break;
case 3:
//PNG
$srcImage = imageCreateFromPng($src);
break;
default:
return false;
break;
}
// resampling
imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destSize[0], $destSize[1], $srcSize[0], $srcSize[1]);
// generating image
switch ($srcSize[2]) {
case 1:
case 2:
imageJpeg($destImage, $dest, $quality);
break;
case 3:
imagePng($destImage, $dest);
break;
}
return true;
} else {
return 'No such File';
}
}
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:60,代码来源:resize.php
示例3: king_def
function king_def()
{
global $king;
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// 过去的时间
header("Content-type: image/png");
$salt = kc_get('salt', 1, 1);
$width = $king->config('verifywidth');
//图片长度
$height = $king->config('verifyheight');
//图片高度
$size = $king->config('verifysize');
//文字大小
$num = $king->config('verifynum');
//文字数量
$content = $king->config('verifycontent');
//随机字符
$array_content = explode('|', $content);
$array_content = array_diff($array_content, array(null));
$array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
$str = '';
$img = imageCreate($width, $height);
//创建一个空白图像
imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
//写字
for ($i = 0; $i < $num; $i++) {
$code = $array_content[array_rand($array_content)];
$str .= $code;
//验证码字符
$color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
$font = 'verify_font/' . $array_font[array_rand($array_font)];
//随机读取一个字体
$left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
}
//画星号
$max = $width * $height / 400;
for ($i = 0; $i < $max; $i++) {
imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
}
//画点
$max = $width * $height / 40;
for ($i = 0; $i < $max; $i++) {
imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
}
//画线
$max = $width * $height / 800;
for ($i = 0; $i < $max; $i++) {
imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
}
//写验证码到verify中
$verify = new KC_Verify_class();
$verify->Put($salt, $str);
imagePng($img);
imageDestroy($img);
$verify->Clear();
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:59,代码来源:verify.php
示例4: CreatePngThumbnail
public static function CreatePngThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $imageNewName)
{
$srcImg = ImageCreateFromPng($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));
imagePng($thumbImg, $thumbDirectory . $imageNewName);
}
开发者ID:brandfeverinc,项目名称:coke-cooler,代码行数:11,代码来源:Helpers.php
示例5: 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
示例6: make_img
function make_img($content)
{
$timage = array(strlen($content) * 20 + 10, 28);
// array(largeur, hauteur) de l'image; ici la largeur est fonction du nombre de lettre du contenu, on peut bien sur mettre une largeur fixe.
$content = preg_replace('/(\\w)/', '\\1 ', $content);
// laisse plus d'espace entre les lettres
$image = imagecreatetruecolor($timage[0], $timage[1]);
// création de l'image
// definition des couleurs
$fond = imageColorAllocate($image, 240, 255, 240);
$grey = imageColorAllocate($image, 210, 210, 210);
$text_color = imageColorAllocate($image, rand(0, 100), rand(0, 50), rand(0, 60));
imageFill($image, 0, 0, $fond);
// on remplit l'image de blanc
//On remplit l'image avec des polygones
for ($i = 0, $imax = mt_rand(3, 5); $i < $imax; $i++) {
$x = mt_rand(3, 10);
$poly = array();
for ($j = 0; $j < $x; $j++) {
$poly[] = mt_rand(0, $timage[0]);
$poly[] = mt_rand(0, $timage[1]);
}
imageFilledPolygon($image, $poly, $x, imageColorAllocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
}
// Création des pixels gris
for ($i = 0; $i < $timage[0] * $timage[1] / rand(15, 18); $i++) {
imageSetPixel($image, rand(0, $timage[0]), rand(0, $timage[1]), $grey);
}
// affichage du texte demandé; on le centre en hauteur et largeur (à peu près ^^")
//imageString($image, 5, ceil($timage[0]-strlen($content)*8)/2, ceil($timage[1]/2)-9, $content, $text_color);
$longueur_chaine = strlen($content);
for ($ch = 0; $ch < $longueur_chaine; $ch++) {
imagettftext($image, 18, mt_rand(-30, 30), 10 * ($ch + 1), mt_rand(18, 20), $text_color, 'res/georgia.ttf', $content[$ch]);
}
$type = function_exists('imageJpeg') ? 'jpeg' : 'png';
@header('Content-Type: image/' . $type);
@header('Cache-control: no-cache, no-store');
$type == 'png' ? imagePng($image) : imageJpeg($image);
ImageDestroy($image);
exit;
}
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:41,代码来源:captcha.php
示例7: 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
示例8: 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
示例9: drawField
function drawField($team)
{
$field = imagecreatefromjpeg("img/field.jpg");
foreach ($team->players as $player) {
$img = drawPlayer($player->number, $player->name);
$width = imagesx($img);
$height = imagesy($img);
$posX = $player->x - ($width - 26) / 2;
$posY = $player->y - 10;
imageAlphaBlending($field, true);
// копировать сюда будем вместе с настройками
imageSaveAlpha($field, true);
// сохраняем
imageCopy($field, $img, $posX, $posY, 0, 0, $width, $height);
//копируем картинку с формой в пустой бокс
}
$copyright = drawCaption("http://www.ezheloko.ru/tactic", 12, 0);
imagecopymerge_alpha($field, $copyright, 240, imagesY($field) - 25, 0, 0, imagesX($copyright), imagesY($copyright), 30);
$name = generateName();
$name = "formations/" . $name . ".png";
imagePng($field, $name);
return $name;
}
开发者ID:renatjudo,项目名称:football-formations-generator,代码行数:23,代码来源:functions.php
示例10: all_project_tree
function all_project_tree($id_user, $completion, $project_kind)
{
include "../include/config.php";
$config["id_user"] = $id_user;
$dotfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.all.dot";
$pngfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.projectall.png";
$mapfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.projectall.map";
$dotfile = fopen($dotfilename, "w");
fwrite($dotfile, "digraph Integria {\n");
fwrite($dotfile, "\t ranksep=1.8;\n");
fwrite($dotfile, "\t ratio=auto;\n");
fwrite($dotfile, "\t size=\"9,9\";\n");
fwrite($dotfile, 'URL="' . $config["base_url"] . '/index.php?sec=projects&sec2=operation/projects/project_tree";' . "\n");
fwrite($dotfile, "\t node[fontsize=" . $config['fontsize'] . "];\n");
fwrite($dotfile, "\t me [label=\"{$id_user}\", style=\"filled\", color=\"yellow\"]; \n");
$total_project = 0;
$total_task = 0;
if ($project_kind == "all") {
$sql1 = "SELECT * FROM tproject WHERE disabled = 0";
} else {
$sql1 = "SELECT * FROM tproject WHERE disabled = 0 AND end != '0000-00-00 00:00:00'";
}
if ($result1 = mysql_query($sql1)) {
while ($row1 = mysql_fetch_array($result1)) {
if (user_belong_project($id_user, $row1["id"], 1) == 1) {
$project[$total_project] = $row1["id"];
$project_name[$total_project] = $row1["name"];
if ($completion < 0) {
$sql2 = "SELECT * FROM ttask WHERE id_project = " . $row1["id"];
} elseif ($completion < 101) {
$sql2 = "SELECT * FROM ttask WHERE completion < {$completion} AND id_project = " . $row1["id"];
} else {
$sql2 = "SELECT * FROM ttask WHERE completion = 100 AND id_project = " . $row1["id"];
}
if ($result2 = mysql_query($sql2)) {
while ($row2 = mysql_fetch_array($result2)) {
if (user_belong_task($id_user, $row2["id"], 1) == 1) {
$task[$total_task] = $row2["id"];
$task_name[$total_task] = $row2["name"];
$task_parent[$total_task] = $row2["id_parent_task"];
$task_project[$total_task] = $project[$total_project];
$task_workunit[$total_task] = get_task_workunit_hours($row2["id"]);
$task_completion[$total_task] = $row2["completion"];
$total_task++;
}
}
}
$total_project++;
}
}
}
// Add project items
for ($ax = 0; $ax < $total_project; $ax++) {
fwrite($dotfile, 'PROY' . $project[$ax] . ' [label="' . wordwrap($project_name[$ax], 12, '\\n') . '", style="filled", color="grey", URL="' . $config["base_url"] . '/index.php?sec=projects&sec2=operation/projects/task&id_project=' . $project[$ax] . '"];');
fwrite($dotfile, "\n");
}
// Add task items
for ($ax = 0; $ax < $total_task; $ax++) {
$temp = 'TASK' . $task[$ax] . ' [label="' . wordwrap($task_name[$ax], 12, '\\n') . '"';
if ($task_completion[$ax] < 10) {
$temp .= 'color="red"';
} elseif ($task_completion[$ax] < 100) {
$temp .= 'color="yellow"';
} elseif ($task_completion[$ax] == 100) {
$temp .= 'color="green"';
}
$temp .= "URL=\"" . $config["base_url"] . "/index.php?sec=projects&sec2=operation/projects/task_detail&id_project=" . $task_project[$ax] . "&id_task=" . $task[$ax] . "&operation=view\"";
$temp .= "];";
fwrite($dotfile, $temp);
fwrite($dotfile, "\n");
}
// Make project attach to user "me"
for ($ax = 0; $ax < $total_project; $ax++) {
fwrite($dotfile, 'me -> PROY' . $project[$ax] . ';');
fwrite($dotfile, "\n");
}
// Make project first parent task relation visible
for ($ax = 0; $ax < $total_task; $ax++) {
if ($task_parent[$ax] == 0) {
fwrite($dotfile, 'PROY' . $task_project[$ax] . ' -> TASK' . $task[$ax] . ';');
fwrite($dotfile, "\n");
}
}
// Make task-subtask parent task relation visible
for ($ax = 0; $ax < $total_task; $ax++) {
if ($task_parent[$ax] != 0) {
fwrite($dotfile, 'TASK' . $task_parent[$ax] . ' -> TASK' . $task[$ax] . ';');
fwrite($dotfile, "\n");
}
}
fwrite($dotfile, "}");
fwrite($dotfile, "\n");
// exec ("twopi -Tpng $dotfilename -o $pngfilename");
exec("twopi -Tcmapx -o{$mapfilename} -Tpng -o{$pngfilename} {$dotfilename}");
Header('Content-type: image/png');
$imgPng = imageCreateFromPng($pngfilename);
imageAlphaBlending($imgPng, true);
imageSaveAlpha($imgPng, true);
imagePng($imgPng);
require $mapfilename;
//.........这里部分代码省略.........
开发者ID:dsyman2,项目名称:integriaims,代码行数:101,代码来源:functions_graph.php
示例11: ImageGif
ImageGif($im1, $imagnam, $quality);
echo "<img src='" . $imagnam . "' alt=''/><br/>";
break;
case "jpg":
$imagnam = "temp/{$namefile}.temp.jpg";
imageJpeg($im1, $imagnam, $quality);
echo "<img src='" . $imagnam . "' alt=''/><br/>";
break;
case "jpeg":
$imagnam = "temp/{$namefile}.temp.jpg";
imageJpeg($im1, $imagnam, $quality);
echo "<img src='" . $imagnam . "' alt=''/><br/>";
break;
case "png":
$imagnam = "temp/{$namefile}.temp.png";
imagePng($im1, $imagnam, $quality);
echo "<img src='" . $imagnam . "' alt=''/><br/>";
break;
}
imagedestroy($im);
imagedestroy($im1);
$kom = mysql_query("select * from `gallery` where type='km' and refid='" . $newf['id'] . "';");
$kom1 = mysql_num_rows($kom);
echo "</a><br/>" . $lng['date'] . ': ' . functions::display_date($newf['time']) . '<br/>' . $lng['description'] . ": {$newf['text']}<br/>";
$al = mysql_query("select * from `gallery` where type = 'al' and id = '" . $newf['refid'] . "';");
$al1 = mysql_fetch_array($al);
$rz = mysql_query("select * from `gallery` where type = 'rz' and id = '" . $al1['refid'] . "';");
$rz1 = mysql_fetch_array($rz);
echo '<a href="index.php?id=' . $al1['id'] . '">' . $rz1['text'] . ' / ' . $al1['text'] . '</a></div>';
}
++$i;
开发者ID:chegestar,项目名称:catroxs,代码行数:31,代码来源:new.php
示例12: createNewImage
private function createNewImage($newImg, $newName, $imgInfo)
{
$this->path = rtrim($this->path, "/") . "/";
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
$result = imagePng($newImg, $this->path . $newName);
break;
}
imagedestroy($newImg);
return $newName;
}
开发者ID:mikelkl,项目名称:online_exam,代码行数:20,代码来源:image.class.php
示例13: count
$charImageStep = $imageWidth / ($charsNumber + 1);
$charWritePoint = $charImageStep;
// Write captcha characters to the image
for ($i = 0; $i < $charsNumber; $i++) {
$nextChar = $characters[mt_rand(0, count($characters) - 1)];
$captchaText .= $nextChar;
// Font properties
$randomFontSize = mt_rand(25, 30);
// Random character size to spice things a little bit :)
$randomFontAngle = mt_rand(-25, 25);
// Twist the character a little bit
$fontType = select_captcha_font();
// This is the font we are using - we need to point to the ttf file here
// Pixels
$pixelX = $charWritePoint;
// We will write a character at this X point
$pixelY = 40;
// We will write a character at this Y point
// Random character color // R // G // B // Alpha
$randomCharColor = imageColorAllocateAlpha($captchaImage, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 25));
// Write a character to the image
imageTtfText($captchaImage, $randomFontSize, $randomFontAngle, $pixelX, $pixelY, $randomCharColor, $fontType, $nextChar);
// Increase captcha step
$charWritePoint += $charImageStep;
}
// Add currently generated captcha text to the session
$_SESSION['login_captcha'] = $captchaText;
// Return the image
return imagePng($captchaImage);
// Destroy captcha image
imageDestroy($captchaImage);
开发者ID:Alimir,项目名称:ajax-bootmodal-login,代码行数:31,代码来源:log-captcha.php
示例14: imageColorAllocate
$textColor = imageColorAllocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
$font = rand(1, 4) . ".ttf";
$randsize = rand($size - $size / 10, $size + $size / 10);
$location = $left + ($i * $size + $size / 10);
imagettftext($image, $randsize, rand(-18, 18), $location, rand($size - $size / 10, $size + $size / 10), $textColor, $font, $randtext);
}
if ($noise == true) {
setnoise();
}
$_SESSION['cv_yzm'] = $code;
$bordercolor = getcolor($bordercolor);
if ($border == true) {
imageRectangle($image, 0, 0, $width - 1, $height - 1, $bordercolor);
}
header("Content-type: image/png");
imagePng($image);
imagedestroy($image);
function getcolor($color)
{
global $image;
$color = eregi_replace("^#", "", $color);
$r = $color[0] . $color[1];
$r = hexdec($r);
$b = $color[2] . $color[3];
$b = hexdec($b);
$g = $color[4] . $color[5];
$g = hexdec($g);
$color = imagecolorallocate($image, $r, $b, $g);
return $color;
}
function setnoise()
开发者ID:songht7,项目名称:brandor,代码行数:31,代码来源:yzm.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
*
* @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
示例16: 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
示例17: fontGif
/**
* Creates a font-preview thumbnail.
* This means a PNG/GIF file with the text "AaBbCc...." set with the font-file given as input and in various sizes to show how the font looks
* Requires GD lib enabled.
* Outputs the image stream to browser and exits!
*
* @param string $font The filepath to the font file (absolute, probably)
* @return void
* @todo Define visibility
*/
public function fontGif($font)
{
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
throw new \RuntimeException('TYPO3 Fatal Error: No gdlib.', 1270853953);
}
// Create image and set background color to white.
$im = imageCreate(250, 76);
$white = imageColorAllocate($im, 255, 255, 255);
$col = imageColorAllocate($im, 0, 0, 0);
// The test string and offset in x-axis.
$string = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÆæØøÅåÄäÖöÜüß';
$x = 13;
// Print (with non-ttf font) the size displayed
imagestring($im, 1, 0, 2, '10', $col);
imagestring($im, 1, 0, 15, '12', $col);
imagestring($im, 1, 0, 30, '14', $col);
imagestring($im, 1, 0, 47, '18', $col);
imagestring($im, 1, 0, 68, '24', $col);
// Print with ttf-font the test string
imagettftext($im, GeneralUtility::freetypeDpiComp(10), 0, $x, 8, $col, $font, $string);
imagettftext($im, GeneralUtility::freetypeDpiComp(12), 0, $x, 21, $col, $font, $string);
imagettftext($im, GeneralUtility::freetypeDpiComp(14), 0, $x, 36, $col, $font, $string);
imagettftext($im, GeneralUtility::freetypeDpiComp(18), 0, $x, 53, $col, $font, $string);
imagettftext($im, GeneralUtility::freetypeDpiComp(24), 0, $x, 74, $col, $font, $string);
// Output PNG or GIF based on $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
header('Content-type: image/png');
imagePng($im);
} else {
header('Content-type: image/gif');
imageGif($im);
}
imagedestroy($im);
die;
}
开发者ID:khanhdeux,项目名称:typo3test,代码行数:45,代码来源:ThumbnailView.php
示例18: debugMode
function debugMode($line, $message, $file = null, $config = null, $message2 = null)
{
global $im, $configData;
// Destroy the image
if (isset($im)) {
imageDestroy($im);
}
if (is_numeric($line)) {
$line -= 1;
}
$error_text = 'Error!';
$line_text = 'Line: ' . $line;
$file = !empty($file) ? 'File: ' . $file : '';
$config = $config ? 'Check the config file' : '';
$message2 = !empty($message2) ? $message2 : '';
$lines = array();
$lines[] = array('s' => $error_text, 'f' => 5, 'c' => 'red');
$lines[] = array('s' => $line_text, 'f' => 3, 'c' => 'blue');
$lines[] = array('s' => $file, 'f' => 2, 'c' => 'green');
$lines[] = array('s' => $message, 'f' => 2, 'c' => 'black');
$lines[] = array('s' => $config, 'f' => 2, 'c' => 'black');
$lines[] = array('s' => $message2, 'f' => 2, 'c' => 'black');
$height = $width = 0;
foreach ($lines as $line) {
if (strlen($line['s']) > 0) {
$line_width = ImageFontWidth($line['f']) * strlen($line['s']);
$width = $width < $line_width ? $line_width : $width;
$height += ImageFontHeight($line['f']);
}
}
$im = @imagecreate($width + 1, $height);
if ($im) {
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$linestep = 0;
foreach ($lines as $line) {
if (strlen($line['s']) > 0) {
imagestring($im, $line['f'], 1, $linestep, utf8_to_nce($line['s']), ${$line}['c']);
$linestep += ImageFontHeight($line['f']);
}
}
switch ($configData['image_type']) {
case 'jpeg':
case 'jpg':
header('Content-type: image/jpg');
@imageJpeg($im);
break;
case 'png':
header('Content-type: image/png');
@imagePng($im);
break;
case 'gif':
default:
header('Content-type: image/gif');
@imagegif($im);
break;
}
imageDestroy($im);
} else {
if (!empty($file)) {
$file = "[<span style=\"color:green\">{$file}</span>]";
}
$string = "<strong><span style=\"color:red\">Error!</span></strong>";
$string .= "<span style=\"color:blue\">Line {$line}:</span> {$message} {$file}\n<br /><br />\n";
if ($config) {
$string .= "{$config}\n<br />\n";
}
if (!empty($message2)) {
$string .= "{$message2}\n";
}
print $string;
}
exit;
}
开发者ID:Sajaki,项目名称:addons,代码行数:77,代码来源:index.php
示例19: imageGif
imageGif($imgNew);
break;
case "jpg":
header('Content-type: image/jpeg');
imageJpeg($imgNew, $cache_path);
imageJpeg($imgNew);
break;
case "jpeg":
header('Content-type: image/jpeg');
imageJpeg($imgNew, $cache_path);
imageJpeg($imgNew);
break;
case "png":
header('Content-type: image/png');
imagePng($imgNew, $cache_path);
imagePng($imgNew);
break;
}
imageDestroy($img);
imageDestroy($imgNew);
// function from docos to convert short-hand notation to bytes
function imageresize_return_bytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val) - 1]);
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
开发者ID:joel-cass,项目名称:structure-cms,代码行数:31,代码来源:image.php
示例20: redimage
//.........这里部分代码省略.........
$dh = $dw;
$dw = round($dh / $sh * $sw);
}
}
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dw, $dh, $sw, $sh);
} else {
// redim the pic according to dest W or dest H
if ($dw == 0 || $dh == 0) {
if ($dw == 0) {
$dw = round($dh / $sh * $sw);
} else {
if ($dh == 0) {
$dh = round($dw / $sw * $sh);
}
}
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dw, $dh, $sw, $sh);
} else {
if ($sw / $sh < $dw / $dh) {
$tw = $sw;
$th = round($sw / $dw * $dh);
$x = 0;
$y = round(($sh - $th) / 2);
$temp_img = ImageCreateTrueColor($tw, $th);
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($temp_img, $src_img, 0, 0, $x, $y, $sw, $sh, $sw, $sh);
ImageCopyResampled($dest_img, $temp_img, 0, 0, 0, 0, $dw, $dh, $tw, $th);
ImageDestroy($temp_img);
} else {
$tw = $sw;
$th = round($sw * ($dh / $dw));
$x = 0;
$y = round(($th - $sh) / 2);
$temp_img = ImageCreateTrueColor($tw, $th);
$dest_img = ImageCreateTrueColor($dw, $dh);
imagefill($temp_img, 0, 0, imagecolorallocate($dest_img, 0, 0, 0));
ImageCopyResampled($temp_img, $src_img, $x, $y, 0, 0, $sw, $sh, $sw, $sh);
ImageCopyResampled($dest_img, $temp_img, 0, 0, 0, 0, $dw, $dh, $tw, $th);
ImageDestroy($temp_img);
}
}
}
}
if ($stamp != false) {
// detect file type (could be a lot better)
$type_stamp = strtoupper(substr($stamp, -3));
// read stamp
switch ($type_stamp) {
case 'JPG':
$stamp_img = ImageCreateFromJpeg($stamp);
break;
case 'PEG':
$stamp_img = ImageCreateFromJpeg($stamp);
break;
case 'GIF':
$stamp_img = ImageCreateFromGif($stamp);
break;
case 'PNG':
$stamp_img = imageCreateFromPng($stamp);
break;
case 'BMP':
$stamp_img = imageCreatefromWBmp($stamp);
break;
}
// get it's info
$size = GetImageSize($stamp);
|
请发表评论