本文整理汇总了PHP中imagecopy函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecopy函数的具体用法?PHP imagecopy怎么用?PHP imagecopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecopy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: overlay
/**
* Overlay an image onto the current image.
*
* @param string $image
* @param int $x
* @param int $y
* @throws Exception
* @return Gd
*/
public function overlay($image, $x = 0, $y = 0)
{
imagealphablending($this->image->resource(), true);
// Create an image resource from the overlay image.
if (stripos($image, '.gif') !== false) {
$overlay = imagecreatefromgif($image);
} else {
if (stripos($image, '.png') !== false) {
$overlay = imagecreatefrompng($image);
} else {
if (stripos($image, '.jp') !== false) {
$overlay = imagecreatefromjpeg($image);
} else {
throw new Exception('Error: The overlay image must be either a JPG, GIF or PNG.');
}
}
}
if ($this->opacity > 0) {
if ($this->opacity == 100) {
imagecopy($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay));
} else {
imagecopymerge($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay), $this->opacity);
}
}
return $this;
}
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:35,代码来源:Gd.php
示例2: run
function run()
{
global $dynbasepath, $rootpath;
$MAX_LEN = 630;
$totalWidth = 0;
$counter = 0;
$im = imagecreatetruecolor($MAX_LEN, 80);
$alpha = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 800, 80, $alpha);
imagecolortransparent($im, $alpha);
$numbers = $this->mrand(1, 50, 50);
while ($totalWidth < $MAX_LEN && $counter < 10) {
$number = $numbers[$counter];
$path = $rootpath . 'images/header/header_' . $number . '.jpg';
$tmp = imagecreatefromjpeg($path);
$totalWidth += imagesx($tmp);
/* echo "total=".$totalWidth;
echo "<br />";
echo "im_".$number."=".imagesx($tmp); */
if ($totalWidth >= $MAX_LEN) {
// return the real width od final logo
$totalWidth -= imagesx($tmp);
break;
}
imagecopy($im, $tmp, $totalWidth - imagesx($tmp), 0, 0, 0, imagesx($tmp), imagesy($tmp));
$counter++;
}
$im_final = imagecreatetruecolor($totalWidth, 80);
imagecopy($im_final, $im, 0, 0, 0, 0, $totalWidth, 80);
imagejpeg($im_final, $rootpath . "images/header/logo.jpg", 90);
imagedestroy($im);
imagedestroy($im_final);
}
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:33,代码来源:make_logo.php
示例3: cuttingimg
function cuttingimg($zoom, $fn, $sz)
{
@mkdir(WUO_ROOT . '/photos/maps');
$img = imagecreatefrompng(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
// получаем идентификатор загруженного изрбражения которое будем резать
$info = getimagesize(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
// получаем в массив информацию об изображении
$w = $info[0];
$h = $info[1];
// ширина и высота исходного изображения
$sx = round($w / $sz, 0);
// длинна куска изображения
$sy = round($h / $sz, 0);
// высота куска изображения
$px = 0;
$py = 0;
// координаты шага "реза"
for ($y = 0; $y <= $sz; $y++) {
for ($x = 0; $x <= $sz; $x++) {
$imgcropped = imagecreatetruecolor($sx, $sy);
imagecopy($imgcropped, $img, 0, 0, $px, $py, $sx, $sy);
imagepng($imgcropped, WUO_ROOT . '/photos/maps/' . $zoom . '-' . $y . '-' . $x . '-' . $fn);
$px = $px + $sx;
}
$px = 0;
$py = $py + $sy;
}
}
开发者ID:solodyagin,项目名称:webuseorg3_lite,代码行数:28,代码来源:uploadimageorg.php
示例4: fill_color
/**
* Background fill an image using the provided color
*
* @param int $width The desired width of the new image
* @param int $height The desired height of the new image
* @param Array the desired pad colors in RGB format, array should be array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' );
*/
private function fill_color(array $colors)
{
$current_size = $this->editor->get_size();
$size = array('width' => $this->args['width'], 'height' => $this->args['height']);
$offsetLeft = ($size['width'] - $current_size['width']) / 2;
$offsetTop = ($size['height'] - $current_size['height']) / 2;
$new_image = imagecreatetruecolor($size['width'], $size['height']);
// This is needed to support alpha
imagesavealpha($new_image, true);
imagealphablending($new_image, false);
// Check if we are padding vertically or horizontally
if ($current_size['width'] != $size['width']) {
$colorToPaint = imagecolorallocatealpha($new_image, substr($colors['left'], 0, 3), substr($colors['left'], 3, 3), substr($colors['left'], 6, 3), substr($colors['left'], 9, 3));
// Fill left color
imagefilledrectangle($new_image, 0, 0, $offsetLeft + 5, $size['height'], $colorToPaint);
$colorToPaint = imagecolorallocatealpha($new_image, substr($colors['right'], 0, 3), substr($colors['right'], 3, 3), substr($colors['right'], 6, 3), substr($colors['left'], 9, 3));
// Fill right color
imagefilledrectangle($new_image, $offsetLeft + $current_size['width'] - 5, 0, $size['width'], $size['height'], $colorToPaint);
} elseif ($current_size['height'] != $size['height']) {
$colorToPaint = imagecolorallocatealpha($new_image, substr($colors['top'], 0, 3), substr($colors['top'], 3, 3), substr($colors['top'], 6, 3), substr($colors['left'], 9, 3));
// Fill top color
imagefilledrectangle($new_image, 0, 0, $size['width'], $offsetTop + 5, $colorToPaint);
$colorToPaint = imagecolorallocatealpha($new_image, substr($colors['bottom'], 0, 3), substr($colors['bottom'], 3, 3), substr($colors['bottom'], 6, 3), substr($colors['left'], 9, 3));
// Fill bottom color
imagefilledrectangle($new_image, 0, $offsetTop - 5 + $current_size['height'], $size['width'], $size['height'], $colorToPaint);
}
imagecopy($new_image, $this->editor->get_image(), $offsetLeft, $offsetTop, 0, 0, $current_size['width'], $current_size['height']);
$this->editor->update_image($new_image);
$this->editor->update_size();
}
开发者ID:shads196770,项目名称:cbox-theme,代码行数:37,代码来源:wpthumb.background-fill.php
示例5: thumbCkeditor
public function thumbCkeditor($new_width = 0, $new_height = 0)
{
list($water_width, $water_height, $water_type) = getimagesize(WATER_DIR);
$water = $this->getImageFrom(WATER_DIR, $water_type);
if (empty($new_height) && empty($new_width)) {
$new_height = $this->height;
$new_width = $this->width;
} elseif (!is_numeric($new_width) || !is_numeric($new_width)) {
$new_height = $this->height;
$new_width = $this->width;
}
//固定一边缩放
if ($this->width > $new_width) {
$new_height = $new_width / $this->width * $this->height;
} else {
$new_width = $this->width;
$new_height = $this->height;
}
if ($this->height > $new_height) {
$new_width = $new_height / $this->height * $this->width;
} else {
$new_width = $this->width;
$new_height = $this->height;
}
//水印的位置
$water_x = $new_width - $water_width - 5;
$water_y = $new_height - $water_height - 5;
//创建一个画布用来存放缩略图
$this->thumb = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($this->thumb, $this->img, 0, 0, 0, 0, $new_width, $new_height, $this->width, $this->height);
if ($new_width > $water_width && $new_height > $water_height) {
imagecopy($this->thumb, $water, $water_x, $water_y, 0, 0, $water_width, $water_height);
}
imagedestroy($water);
}
开发者ID:zhendeguoke1008,项目名称:shop-1,代码行数:35,代码来源:Image.class.php
示例6: putImage
/**
* method puts image onto map image
*
* @param Map $map
* @param resources $imageToPut
*/
public function putImage(Map $map, $imageToPut)
{
$mapImage = $map->getImage();
$width = imagesx($imageToPut);
$height = imagesy($imageToPut);
imagecopy($mapImage, $imageToPut, imagesx($mapImage) - $width, 0, 0, 0, $width, $height);
}
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:13,代码来源:RightUpCorner.php
示例7: render
public function render(Job $job)
{
$format = $this->configuration->getString('format', 'png');
$defaultColor = $format == 'png' ? 0x0 : 0xffffffff;
$backgroundColor = $this->configuration->getColor('background', $defaultColor);
foreach ($job->spritesheets as $spritesheet) {
/** @var Spritesheet $spritesheet */
$image = ImageTools::createImage($spritesheet->width, $spritesheet->height, $backgroundColor);
foreach ($spritesheet->sprites as $sprite) {
$repeatY = $sprite->repeatY;
while ($repeatY--) {
$repeatX = $sprite->repeatX;
while ($repeatX--) {
imagecopy($image, $sprite->image, $sprite->spriteX + $sprite->paddingLeft + $repeatX * $sprite->width, $sprite->spriteY + $sprite->paddingTop + $repeatY * $sprite->height, 0, 0, $sprite->width, $sprite->height);
}
}
}
$output = $this->mosaic->getPath($this->configuration->getString('outputFolder', Configuration::VALUE_REQUIRED));
$encodedSpritesheetPath = Tools::encodeFilePath($output . '/' . $spritesheet->name . '.' . $format);
FileTools::createDirectory(dirname($encodedSpritesheetPath));
if ($format == 'png') {
imagepng($image, $encodedSpritesheetPath, 9, E_ALL);
} elseif ($format == 'jpg') {
imagejpeg($image, $encodedSpritesheetPath, $this->configuration->getInt('quality', 90));
}
imagedestroy($image);
$encodedSpritesheetPath = realpath($encodedSpritesheetPath);
if (!$encodedSpritesheetPath) {
throw new \Exception('Could not verify rendered spritesheet path.');
}
// Normalize output path
$spritesheet->path = Tools::decodeFilePath($encodedSpritesheetPath);
}
}
开发者ID:cyantree,项目名称:mosaic,代码行数:34,代码来源:BasicRenderer.php
示例8: watermark
function watermark($image, $mimeType, $imgWidth, $imgHeight, $watermark, $watermarkHeight, $watermarkWidth, $position = "center")
{
// Calculate the watermark position
switch ($position) {
case "center":
$marginBottom = round($imgHeight / 2);
$marginRight = round($imgWidth / 2) - round($watermarkWidth / 2);
break;
case "top-left":
$marginBottom = round($imgHeight - $watermarkHeight);
$marginRight = round($imgWidth - $watermarkWidth);
break;
case "bottom-left":
$marginBottom = 5;
$marginRight = round($imgWidth - $watermarkWidth);
break;
case "top-right":
$marginBottom = round($imgHeight - $watermarkHeight);
$marginRight = 5;
break;
default:
$marginBottom = 2;
$marginRight = 2;
break;
}
$watermark = imagecreatefrompng($watermark);
switch ($mimeType) {
case "jpeg":
case "jpg":
$createImage = imagecreatefromjpeg($image);
break;
case "png":
$createImage = imagecreatefrompng($image);
break;
case "gif":
$createImage = imagecreatefromgif($image);
break;
default:
$createImage = imagecreatefromjpeg($image);
break;
}
$sx = imagesx($watermark);
$sy = imagesy($watermark);
imagecopy($createImage, $watermark, imagesx($createImage) - $sx - $marginRight, imagesy($createImage) - $sy - $marginBottom, 0, 0, imagesx($watermark), imagesy($watermark));
switch ($mimeType) {
case "jpeg":
case "jpg":
imagejpeg($createImage, $image);
break;
case "png":
imagepng($createImage, $image);
break;
case "gif":
imagegif($createImage, $image);
break;
default:
throw new \Exception("A watermark can only be applied to: jpeg, jpg, gif, png images ");
break;
}
}
开发者ID:JoaoBGusmao,项目名称:qualdosdois,代码行数:60,代码来源:func.image-watermark.php
示例9: imagemergealpha
function imagemergealpha($i)
{
//create a new image
$s = imagecreatetruecolor(imagesx($i[0]), imagesy($i[1]));
$back_color = imagecolorallocate($s, 0xa9, 0xb1, 0xd3);
//merge all images
imagealphablending($s, true);
$z = $i;
while ($d = each($z)) {
imagecopy($s, $d[1], 0, 0, 0, 0, imagesx($d[1]), imagesy($d[1]));
}
//restore the transparency
imagealphablending($s, false);
$w = imagesx($s);
$h = imagesy($s);
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$c = imagecolorat($s, $x, $y);
$c = imagecolorsforindex($s, $c);
$z = $i;
$t = 0;
while ($d = each($z)) {
$ta = imagecolorat($d[1], $x, $y);
$ta = imagecolorsforindex($d[1], $ta);
$t += 127 - $ta['alpha'];
}
$t = $t > 127 ? 127 : $t;
$t = 127 - $t;
$c = imagecolorallocatealpha($s, $c['red'], $c['green'], $c['blue'], $t);
imagesetpixel($s, $x, $y, $c);
}
}
imagesavealpha($s, true);
return $s;
}
开发者ID:relaismago,项目名称:outils,代码行数:35,代码来源:wanted.php
示例10: creaMapa
function creaMapa($usuario, $img, $pantalla, $nombre, $nFil, $nCol)
{
$nombreComp = dirname(__DIR__) . "/../img/mapasUsuarios/{$nombre}.png";
//GUARDO UN FICHERO .PNG CON LA IMAGEN DE LA PANTALLA
//Creo una imagen en memoria a partir de la cadena en base64:pacman/autogenerados
$im = imagecreatefromstring($img);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
//imagedestroy($im);
} else {
echo 'An error occurred.';
}
//Creo el fichero para almacenar la imagen creada en memoria
$ancho = 10 * $nCol;
$alto = 10 * $nFil;
$nuevaImg = imagecreatetruecolor($ancho, $alto);
imagecopy($nuevaImg, $im, 0, 0, 0, 0, $ancho, $alto);
imagepng($nuevaImg, $nombreComp);
//El directorio esta en $nombreComp
imagedestroy($nuevaImg);
imagedestroy($im);
//LLAMO A CONSULTAS PARA HACER LA INSERCION EN BBDD
include_once dirname(__DIR__) . "/dao/consultas.php";
$chulta = metePantalla($pantalla, $nombre, $usuario, $nFil, $nCol);
return $chulta;
}
开发者ID:ElbUko,项目名称:juegoskeleto,代码行数:27,代码来源:pacmanGuardaMapa.php
示例11: execute
/**
* Reduces colors of a given image
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$count = $this->argument(0)->value();
$matte = $this->argument(1)->value();
// get current image size
$size = $image->getSize();
// create empty canvas
$resource = imagecreatetruecolor($size->width, $size->height);
// define matte
if (is_null($matte)) {
$matte = imagecolorallocatealpha($resource, 255, 255, 255, 127);
} else {
$matte = $image->getDriver()->parseColor($matte)->getInt();
}
// fill with matte and copy original image
imagefill($resource, 0, 0, $matte);
// set transparency
imagecolortransparent($resource, $matte);
// copy original image
imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
if (is_numeric($count) && $count <= 256) {
// decrease colors
imagetruecolortopalette($resource, true, $count);
}
// set new resource
$image->setCore($resource);
return true;
}
开发者ID:shubhomoy,项目名称:evolve,代码行数:34,代码来源:LimitColorsCommand.php
示例12: __clone
/**
* Method called when 'clone' keyword is used.
*/
public function __clone()
{
$original = $this->gd;
$copy = imagecreatetruecolor($this->width, $this->height);
imagecopy($copy, $original, 0, 0, 0, 0, $this->width, $this->height);
$this->gd = $copy;
}
开发者ID:kosinix,项目名称:grafika,代码行数:10,代码来源:Image.php
示例13: add_water
protected function add_water($src, $width, $height)
{
if ($this->waterimg and is_numeric($this->arg["water_scope"]) and $width > $this->arg["water_scope"] and $height > $this->arg["water_scope"]) {
imagecopy($src, $this->waterimg[0], $width - $this->waterimg[1] - 10, $height - $this->waterimg[2] - 10, 0, 0, $this->waterimg[1], $this->waterimg[2]);
}
return $src;
}
开发者ID:ZH9009,项目名称:jjczj,代码行数:7,代码来源:zip_img.php
示例14: process
public function process(Image $image)
{
$destCanvas = $image->getCanvas();
$destImageMetrics = $image->getMetrics();
$watermarkImage = $this->getWaterMarkSource();
$wmWidth = $this->watermarkMetrics[0];
$wmHeight = $this->watermarkMetrics[1];
$wmImageType = $this->watermarkMetrics[2];
$destinationX = "";
$destinationY = "";
switch ($this->position) {
case self::TOP_LEFT:
$destinationX = $destImageMetrics->sourceWidth - $destImageMetrics->sourceWidth;
$destinationY = $destImageMetrics->sourceHeight - $destImageMetrics->sourceHeight;
break;
case self::TOP_RIGHT:
$destinationX = $destImageMetrics->sourceWidth - $wmWidth - 15;
$destinationY = $destImageMetrics->sourceHeight - $destImageMetrics->sourceHeight;
break;
case self::BOTTOM_LEFT:
$destinationX = $destImageMetrics->sourceWidth - $destImageMetrics->sourceWidth;
$destinationY = $destImageMetrics->sourceHeight - $wmHeight - 15;
break;
case self::BOTTOM_RIGHT:
$destinationX = $destImageMetrics->sourceWidth - $wmWidth - 15;
$destinationY = $destImageMetrics->sourceHeight - $wmHeight - 15;
break;
}
imagecopy($destCanvas, $watermarkImage, $destinationX, $destinationY, 0, 0, $wmWidth, $wmHeight);
}
开发者ID:RhubarbPHP,项目名称:Module.ImageProcessing,代码行数:30,代码来源:ImageProcessAddWatermark.php
示例15: save
/**
* Save image to specific path.
* If some folders of path does not exist they will be created
*
* @throws Exception if destination path is not writable
* @param string $destination
* @param string $newName
*/
public function save($destination = null, $newName = null)
{
$fileName = $this->_prepareDestination($destination, $newName);
if (!$this->_resized) {
// keep alpha transparency
$isAlpha = false;
$isTrueColor = false;
$this->_getTransparency($this->_imageHandler, $this->_fileType, $isAlpha, $isTrueColor);
if ($isAlpha) {
if ($isTrueColor) {
$newImage = imagecreatetruecolor($this->_imageSrcWidth, $this->_imageSrcHeight);
} else {
$newImage = imagecreate($this->_imageSrcWidth, $this->_imageSrcHeight);
}
$this->_fillBackgroundColor($newImage);
imagecopy($newImage, $this->_imageHandler, 0, 0, 0, 0, $this->_imageSrcWidth, $this->_imageSrcHeight);
$this->_imageHandler = $newImage;
}
}
$functionParameters = array($this->_imageHandler, $fileName);
$quality = $this->quality();
if ($quality !== null) {
if ($this->_fileType == IMAGETYPE_PNG) {
// for PNG files quality param must be from 0 to 10
$quality = ceil($quality / 10);
if ($quality > 10) {
$quality = 10;
}
$quality = 10 - $quality;
}
$functionParameters[] = $quality;
}
call_user_func_array($this->_getCallback('output'), $functionParameters);
}
开发者ID:nemphys,项目名称:magento2,代码行数:42,代码来源:Gd2.php
示例16: build
/**
* Build the CSS sprite in memory
* @return Tinyfier_Image_Tool
*/
public function build()
{
//Sort images inside the sprite
$y = 0;
foreach ($this->_images as $image) {
$image->top = $y;
$image->left = 0;
$y += $image->image->height();
}
//Draw sprite
$w = 0;
$h = 0;
foreach ($this->_images as $image) {
$w = max($w, $image->left + $image->image->width());
$h = max($w, $image->top + $image->image->height());
}
$sprite = imagecreatetruecolor($w, $h);
imagealphablending($sprite, false);
//Soporte de transparencias
imagefill($sprite, 0, 0, imagecolorallocatealpha($sprite, 0, 0, 0, 127));
//Fondo transparente
foreach ($this->_images as $image) {
imagecopy($sprite, $image->image->handle(), $image->left, $image->top, 0, 0, $image->image->width(), $image->image->height());
}
return new Tinyfier_Image_Tool($sprite);
}
开发者ID:ideatic,项目名称:tinyfier,代码行数:30,代码来源:Sprite.php
示例17: watermark
function watermark($path)
{
// this script creates a watermarked image from an image file - can be a .jpg .gif or .png file
// where watermark.gif is a mostly transparent gif image with the watermark - goes in the same directory as this script
// where this script is named watermark.php
// call this script with an image tag
// <img src="watermark.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
//$imagesource = $_GET['path'];
$imagesource = $path;
$filetype = substr($imagesource, strlen($imagesource) - 4, 4);
$filetype = strtolower($filetype);
if ($filetype == ".gif") {
$image = @imagecreatefromgif($imagesource);
}
if ($filetype == ".jpg") {
$image = @imagecreatefromjpeg($imagesource);
}
if ($filetype == ".png") {
$image = @imagecreatefrompng($imagesource);
}
if (!$image) {
die;
}
$watermark = @imagecreatefromgif($basepath . '/wp-content/plugins/wp-shopping-cart/images/watermark.gif');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = ($imagewidth - $watermarkwidth) / 2;
$startheight = ($imageheight - $watermarkheight) / 2;
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
}
开发者ID:laiello,项目名称:cartonbank,代码行数:35,代码来源:image_preview.php
示例18: cuttingimg
function cuttingimg($zoom, $fn, $sz)
{
$img = imagecreatefrompng("../../../photos/maps/" . '0-0-0-' . $fn);
// получаем идентификатор загруженного изрбражения которое будем резать
$info = getimagesize("../../../photos/maps/" . '0-0-0-' . $fn);
// получаем в массив информацию об изображении
$w = $info[0];
$h = $info[1];
// ширина и высота исходного изображения
$sx = round($w / $sz, 0);
// длинна куска изображения
$sy = round($h / $sz, 0);
// высота куска изображения
$px = 0;
$py = 0;
// координаты шага "реза"
//echo "-- $sx,$sy -- $w/$h -- $img !";
//print_r($info);
for ($y = 0; $y <= $sz; $y++) {
for ($x = 0; $x <= $sz; $x++) {
$imgcropped = imagecreatetruecolor($sx, $sy);
imagecopy($imgcropped, $img, 0, 0, $px, $py, $sx, $sy);
imagepng($imgcropped, "../../../photos/maps/" . $zoom . "-" . $y . "-" . $x . "-" . $fn);
$px = $px + $sx;
//echo "../../images/maps/".$y."-".$x."-".$fn;
}
$px = 0;
$py = $py + $sy;
}
// return "ok";
}
开发者ID:Kozlov-V,项目名称:webuseorg3,代码行数:31,代码来源:uploadimageorg.php
示例19: createPingImg
public static function createPingImg($imgurl, $ping = ImageHelper::PING_BASE_RED)
{
$ping = Url::to($ping);
//ファイルから新規にJPEG画像を作成する
$image_back = imagecreatefrompng($ping);
$image_alpha = static::createImageByMask($imgurl);
//背景画像の幅と高さを取得
list($width, $height, $type, $attr) = getimagesize($ping);
//合成する画像をちょいとずらしてみる
$x = 32;
$y = 32;
//imagealphablending($image_back, false);
//imagealphablending($image_alpha, false);
imagesavealpha($image_back, true);
imagesavealpha($image_alpha, true);
//画像を合成する
imagecopy($image_back, $image_alpha, $x, $y, 0, 0, imagesx($image_alpha), imagesy($image_alpha));
//合成した画像を出力
//header("Content-type: image/png");
//imagepng($image_back);
$filename = basename($imgurl, ".jpg") . ".png";
$filepath = Url::to(static::PING_IMG_DIR) . $filename;
imagepng($image_back, $filepath);
//メモリから解放
imagedestroy($image_back);
imagedestroy($image_alpha);
}
开发者ID:RyosukeMurai,项目名称:TokyoSearch,代码行数:27,代码来源:ImageHelper.php
示例20: merge
function merge($width, $height)
{
$array_variable = get_variable();
$bg = $array_variable[0];
$over = $array_variable[1];
$outputFile = $array_variable[2];
$result = $array_variable[3];
$path_to_save = $array_variable[4];
$n = $array_variable[5];
$tmp_img = $path_to_save . "/tmp_" . $n . ".png";
// $result_jpg_compressed = $path_to_save.'/'.$n.'.JPG';
// $base_image = imagecreatefrompng($bg);
jpg2png($bg, $outputFile);
$base_image = imagecreatefrompng($outputFile);
$top_image = imagecreatefrompng($over);
// $merged_image = $result;
imagesavealpha($top_image, true);
imagealphablending($top_image, true);
imagecopy($base_image, $top_image, 0, 0, 0, 0, $width, $height);
imagepng($base_image, $result);
// rename to temp for compression
rename($result, $path_to_save . "/tmp_" . $n . ".png");
// compress IMG
$img = imagecreatefrompng($tmp_img);
// imagejpeg($img,$result_jpg_compressed,75);
imagejpeg($img, $result, 75);
unlink($tmp_img);
unlink($tmp_img);
// if necessery !!!!!!!!!!!!!!!!!!!
unlink($outputFile);
unlink($over);
}
开发者ID:vincseize,项目名称:GDC,代码行数:32,代码来源:saveCanvas_OLD1.php
注:本文中的imagecopy函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论