本文整理汇总了PHP中imageCopy函数的典型用法代码示例。如果您正苦于以下问题:PHP imageCopy函数的具体用法?PHP imageCopy怎么用?PHP imageCopy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize_image_crop
function resize_image_crop($src_image, $width, $height)
{
$src_width = imageSX($src_image);
$src_height = imageSY($src_image);
$width = $width <= 0 ? $src_width : $width;
$height = $height <= 0 ? $src_height : $height;
$prop_width = $src_width / $width;
$prop_height = $src_height / $height;
if ($prop_height > $prop_width) {
$crop_width = $src_width;
$crop_height = round($prop_width * $height);
$srcX = 0;
$srcY = round($src_height / 2) - round($crop_height / 2);
} else {
$crop_width = round($prop_height * $width);
$crop_height = $src_height;
$srcX = round($src_width / 2) - round($crop_width / 2);
$srcY = 0;
}
$new_image = imageCreateTrueColor($width, $height);
$tmp_image = imageCreateTrueColor($crop_width, $crop_height);
imageCopy($tmp_image, $src_image, 0, 0, $srcX, $srcY, $crop_width, $crop_height);
imageCopyResampled($new_image, $tmp_image, 0, 0, 0, 0, $width, $height, $crop_width, $crop_height);
imagedestroy($tmp_image);
image_unsharp_mask($new_image);
return $new_image;
}
示例2: execute
/**
* Method to apply a background color to an image resource.
*
* @param array $options An array of options for the filter.
* color Background matte color
*
* @return void
*
* @since 3.4
* @throws InvalidArgumentException
* @deprecated 5.0 Use Joomla\Image\Filter\Backgroundfill::execute() instead
*/
public function execute(array $options = array())
{
// Validate that the color value exists and is an integer.
if (!isset($options['color'])) {
throw new InvalidArgumentException('No color value was given. Expected string or array.');
}
$colorCode = !empty($options['color']) ? $options['color'] : null;
// Get resource dimensions
$width = imagesX($this->handle);
$height = imagesY($this->handle);
// Sanitize color
$rgba = $this->sanitizeColor($colorCode);
// Enforce alpha on source image
if (imageIsTrueColor($this->handle)) {
imageAlphaBlending($this->handle, false);
imageSaveAlpha($this->handle, true);
}
// Create background
$bg = imageCreateTruecolor($width, $height);
imageSaveAlpha($bg, empty($rgba['alpha']));
// Allocate background color.
$color = imageColorAllocateAlpha($bg, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
// Fill background
imageFill($bg, 0, 0, $color);
// Apply image over background
imageCopy($bg, $this->handle, 0, 0, 0, 0, $width, $height);
// Move flattened result onto curent handle.
// If handle was palette-based, it'll stay like that.
imageCopy($this->handle, $bg, 0, 0, 0, 0, $width, $height);
// Free up memory
imageDestroy($bg);
return;
}
示例3: watermark
public function watermark()
{
$imagecreatefromfunc = $this->_imagecreatefromfunc;
$imagefunc = $this->_imagefunc;
list($img_w, $img_h) = $this->_imageinfo;
$watermark_file = 'D:/www/phpweb20/public/watermark.png';
$watermarkinfo = @getimagesize($watermark_file);
$watermark_logo = @imagecreatefrompng($watermark_file);
if (!$watermark_logo) {
return;
}
list($logo_w, $logo_h) = $watermarkinfo;
$x = $img_w - $logo_w - 5;
$y = $img_h - $logo_h - 5;
$dst_photo = imagecreatetruecolor($img_w, $img_h);
$image_photo = @$imagecreatefromfunc($this->_imagefile);
imagecopy($dst_photo, $image_photo, 0, 0, 0, 0, $img_w, $img_h);
imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
clearstatcache();
if ($this->_imageinfo[2] == 2) {
$imagefunc($dst_photo, $this->_imagefile, 80);
} else {
$imagefunc($dst_photo, $this->_imagefile);
}
}
示例4: asTrueColor
function asTrueColor()
{
$width = $this->getWidth();
$height = $this->getHeight();
$new = wiTrueColorImage::create($width, $height);
if ($this->isTransparent()) {
$new->copyTransparencyFrom($this);
}
imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height);
return $new;
}
示例5: 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();
}
示例6: watermask
function watermask($targetfile, $logofile)
{
$imagetype = array("1" => "gif", "2" => "jpeg", "3" => "png", "4" => "wbmp");
$targetinfo = getimagesize($targetfile);
$imagecreatefromfunc = "imagecreatefrom" . $imagetype[$targetinfo[2]];
$imagefunc = "image" . $imagetype[$targetinfo[2]];
list($img_w, $img_h) = $targetinfo;
$watermarkinfo = getimagesize($logofile);
$watermark = imageCreateFromPNG($logofile);
list($logo_w, $logo_h) = $watermarkinfo;
$x = $img_w - $logo_w - 5;
$y = $img_h - $logo_h - 5;
$dst_photo = imagecreatetruecolor($img_w, $img_h);
$target_photo = @$imagecreatefromfunc($targetfile);
imageCopy($dst_photo, $target_photo, 0, 0, 0, 0, $img_w, $img_h);
imageCopy($dst_photo, $watermark, $x, $y, 0, 0, $logo_w, $logo_h);
clearstatcache();
$imagefunc($dst_photo, $targetfile, 80);
}
示例7: addWaterMarkImage
/**
* Add a Water Mark to the image
* (filigrana)
*
* @param string $from
* @param string $waterMark
*/
public function addWaterMarkImage($waterMark, $opacity = 35, $x = 5, $y = 5)
{
// set data
$size = $this->info;
$im = $this->gdID;
// set WaterMark's data
$waterMarkSM = new SmartImage($waterMark);
$imWM = $waterMarkSM->getGDid();
// Add it!
// In png watermark images we ignore the opacity (you have to set it in the watermark image)
if ($waterMarkSM->info[2] == 3) {
imageCopy($im, $imWM, $x, $y, 0, 0, imagesx($imWM), imagesy($imWM));
} else {
imageCopyMerge($im, $imWM, $x, $y, 0, 0, imagesx($imWM), imagesy($imWM), $opacity);
}
$waterMarkSM->close();
$this->gdID = $im;
}
示例8: createpng
function createpng($tag = 0, $gray = 0, $fuzzy = 0, $x = 1, $y = 1, $debug_flag = 0, $borders = array())
{
global $tmppath;
global $tilecachepath;
$v3img = dirname(__FILE__) . "/../imgs/v3image2.png";
if ($this->createfromim == 1) {
// just load image from im or filename
$cim = $this->im;
} else {
// load from STB files
$pscount = 1;
$pstotal = $this->shiftx * $this->shifty;
$this->doLog("check tiles...");
for ($j = $this->starty; $j > $this->starty - $this->shifty; $j--) {
for ($i = $this->startx; $i < $this->startx + $this->shiftx; $i++) {
//error_log("call $i $j");
list($status, $fname) = img_from_tiles($this->stbdir, $i * 1000, $j * 1000, 1, 1, $this->zoom, $this->ph, $debug_flag, $tmppath, $tilecachepath);
// 產生 progress
$this->doLog("{$pscount} / {$pstotal}");
$this->doLog(sprintf("ps%%+%d", 20 * $pscount / $pstotal));
$pscount++;
if ($status === FALSE) {
error_log("error {$fname}");
$this->err[] = $fname;
return FALSE;
}
$fn[] = $fname;
}
}
//print_r($fn);
// 合併
$this->doLog("merge tiles...");
$outi = $outimage = tempnam($tmppath, "MTILES");
$montage_bin = "montage";
$cmd = sprintf("{$montage_bin} %s -mode Concatenate -tile %dx%d miff:-| composite -gravity northeast %s - miff:-| convert - -resize %dx%d\\! png:%s", implode(" ", $fn), $this->shiftx, $this->shifty, $v3img, $this->shiftx * 315, $this->shifty * 315, $outi);
if ($debug_flag) {
$this->doLog($cmd);
}
exec($cmd);
$cim = imagecreatefrompng($outi);
exec("rm " . implode(" ", $fn) . " {$outi}");
// $cim=cropimage($im,$this->movX,$this->movY,
// $this->shiftx * 315 + $fuzzy,
// $this->shifty * 315 + $fuzzy );
}
if ($tag == 1) {
// echo "tag it ...\n";
$this->doLog("tagimage ...");
$cim = tagimage($cim, $this->startx, $this->starty, $fuzzy);
} else {
if ($tag == 2) {
if ($this->outsizex == 0 || $this->outsizey == 0) {
$this->err[] = "Please call setoutsize() first\n";
return FALSE;
}
if ($this->createfromim == 0 && ($this->shiftx < $this->outsizex || $this->shifty < $this->outsizey)) {
// echo "resizing image...\n";
$dst = imageCreate($this->outsizex * 315 + $fuzzy, $this->outsizey * 315 + $fuzzy);
$bgcolor = imagecolorallocate($dst, 255, 255, 255);
imagefill($dst, 0, 0, $bgcolor);
imageCopy($dst, $cim, 0, 0, 0, 0, imageSX($cim), imageSY($cim));
$cim = $dst;
}
// refer to X,Y, I
// debug: echo "addtagbprder2 cim $x $y $d $this->startx, $this->starty, 4x6, $this->shiftx, $this->shifty $fuzzy \n";
$this->doLog("add borders ...");
$cim = addtagborder2($cim, $x, $y, $debug_flag, $this->startx, $this->starty, array("x" => $this->outsizex, "y" => $this->outsizey), $this->shiftx, $this->shifty, $fuzzy);
if (!($x == 1 && $y == 1)) {
// echo "add boder to cut or paste...\n";
$cim = addborder2($cim, $x, $y, $debug_flag, $borders);
}
}
}
if ($gray >= 1) {
// $cim = grayscale($cim);
//grayscale2($cim);
$this->doLog("grayscale image ...");
$cim = im_grayscale($cim);
}
return $cim;
}
示例9: __flop
/**
* Horizontally mirror (flop) the image
*
* @param Asido_Image &$image
* @return boolean
* @access protected
*/
function __flop(&$tmp) {
$t = imageCreateTrueColor($tmp->image_width, $tmp->image_height);
imageAlphaBlending($t, true);
for ($x = 0; $x < $tmp->image_width; ++$x) {
imageCopy(
$t,
$tmp->target,
$x, 0,
$tmp->image_width - $x - 1, 0,
1, $tmp->image_height
);
}
imageAlphaBlending($t, false);
$this->__destroy_target($tmp);
$tmp->target = $t;
return true;
}
示例10: makewatermark
function makewatermark($srcfile)
{
global $_SCONFIG;
if ($_SCONFIG['watermark'] && function_exists('imageCreateFromJPEG') && function_exists('imageCreateFromPNG') && function_exists('imageCopyMerge')) {
$srcfile = A_DIR . '/' . $srcfile;
$watermark_file = $_SCONFIG['watermarkfile'];
$watermarkstatus = $_SCONFIG['watermarkstatus'];
$fileext = fileext($watermark_file);
$ispng = $fileext == 'png' ? true : false;
$attachinfo = @getimagesize($srcfile);
if (!empty($attachinfo) && is_array($attachinfo) && $attachinfo[2] != 1 && $attachinfo['mime'] != 'image/gif') {
} else {
return '';
}
$watermark_logo = $ispng ? @imageCreateFromPNG($watermark_file) : @imageCreateFromGIF($watermark_file);
if (!$watermark_logo) {
return '';
}
$logo_w = imageSX($watermark_logo);
$logo_h = imageSY($watermark_logo);
$img_w = $attachinfo[0];
$img_h = $attachinfo[1];
$wmwidth = $img_w - $logo_w;
$wmheight = $img_h - $logo_h;
if (is_readable($watermark_file) && $wmwidth > 100 && $wmheight > 100) {
switch ($attachinfo['mime']) {
case 'image/jpeg':
$dst_photo = imageCreateFromJPEG($srcfile);
break;
case 'image/gif':
$dst_photo = imageCreateFromGIF($srcfile);
break;
case 'image/png':
$dst_photo = imageCreateFromPNG($srcfile);
break;
default:
break;
}
switch ($watermarkstatus) {
case 1:
$x = +5;
$y = +5;
break;
case 2:
$x = ($img_w - $logo_w) / 2;
$y = +5;
break;
case 3:
$x = $img_w - $logo_w - 5;
$y = +5;
break;
case 4:
$x = +5;
$y = ($img_h - $logo_h) / 2;
break;
case 5:
$x = ($img_w - $logo_w) / 2;
$y = ($img_h - $logo_h) / 2;
break;
case 6:
$x = $img_w - $logo_w - 5;
$y = ($img_h - $logo_h) / 2;
break;
case 7:
$x = +5;
$y = $img_h - $logo_h - 5;
break;
case 8:
$x = ($img_w - $logo_w) / 2;
$y = $img_h - $logo_h - 5;
break;
case 9:
$x = $img_w - $logo_w - 5;
$y = $img_h - $logo_h - 5;
break;
}
if ($ispng) {
$watermark_photo = imagecreatetruecolor($img_w, $img_h);
imageCopy($watermark_photo, $dst_photo, 0, 0, 0, 0, $img_w, $img_h);
imageCopy($watermark_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
$dst_photo = $watermark_photo;
} else {
imageAlphaBlending($watermark_logo, true);
imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $_SCONFIG['watermarktrans']);
}
switch ($attachinfo['mime']) {
case 'image/jpeg':
imageJPEG($dst_photo, $srcfile, $_SCONFIG['watermarkjpgquality']);
break;
case 'image/gif':
imageGIF($dst_photo, $srcfile);
break;
case 'image/png':
imagePNG($dst_photo, $srcfile);
break;
}
}
}
}
示例11: imagecreatetruecolor
if ($width / $height > $ratio_orig) {
$width = $height * $ratio_orig;
} else {
$height = $width / $ratio_orig;
}
# Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($konyvtar . '/' . $fajlnev_n);
if ($degrees != "") {
// Create a square image the size of the largest side of our src image
$kulonb = ($width_orig - $height_orig) / 2;
$tmp = imageCreateTrueColor($width_orig, $width_orig);
// Exchange sides
$image_p = imageCreateTrueColor($height, $width);
// Now copy our src image to tmp where we will rotate and then copy that to $out
imageCopy($tmp, $image, 0, $kulonb, 0, 0, $width_orig, $height_orig);
$tmp2 = imageRotate($tmp, $degrees, 0);
// Now copy tmp2 to $out;
#majd kicsinyíteni a kívánt méretre
imagecopyresampled($image_p, $tmp2, 0, 0, $kulonb, 0, $width, $height + 200, $width_orig, $width_orig);
} else {
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
}
# Output
imagejpeg($image_p, $konyvtar . '/' . $fajlnev_n);
imagedestroy($image_p);
#a képek adatainak rögzítése az adatbázisba
if ($nincsfajl != 1) {
$sql2 = "INSERT INTO " . $_SESSION[adatbazis_etag] . "_galeriakepek (sorszam, fajlnev_nagy, felirat_hu, csoport, kepszam) values ('{$num_rows}', '{$fajlnev_n}', '{$_REQUEST['felirat_hu']}', '{$_REQUEST['csoport']}', '{$num_rowkeps}')";
mysql_query($sql2);
}
示例12: applyWatermark
function applyWatermark($options = array('image_to_modify' => null, 'watermark_image' => null))
{
$watermark = imageCreateFromPNG($options['watermark_image']);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imageCreateTrueColor($watermark_width, $watermark_height);
$image = imageCreateFromJPEG($options['image_to_modify']);
$size = getImageSize($options['image_to_modify']);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imageCopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
if (imageJPEG($image, $options['image_to_modify'], $quality = 100)) {
// TODO REFACTOR: To work for gif and png from trent's code
imageDestroy($image);
imageDestroy($watermark);
return true;
} else {
imageDestroy($image);
imageDestroy($watermark);
return false;
}
}
示例13: mergeTwoImages
/**
* Merge two image var
*
* @param resource $destinationImage
* @param resource $sourceImage
* @param integer $destinationPosX
* @param integer $destinationPosY
* @param integer $sourcePosX
* @param integer $sourcePosY
*/
public static function mergeTwoImages(&$destinationImage, $sourceImage, $destinationPosX = 0, $destinationPosY = 0, $sourcePosX = 0, $sourcePosY = 0)
{
imageCopy($destinationImage, $sourceImage, $destinationPosX, $destinationPosY, $sourcePosX, $sourcePosY, imageSX($sourceImage), imageSY($sourceImage));
}
示例14: Watermark_GD
function Watermark_GD()
{
if (function_exists('imagecopy') && function_exists('imagealphablending') && function_exists('imagecopymerge')) {
$imagecreatefromfunc = $this->imagecreatefromfunc;
$imagefunc = $this->imagefunc;
list($img_w, $img_h) = $this->attachinfo;
if ($this->watermarktype < 2) {
//非文本
$watermark_file = HDWIKI_ROOT . './style/default/watermark/logo.' . ($this->watermarktype == 1 ? 'png' : 'gif');
$watermarkinfo = @getimagesize($watermark_file);
$watermark_logo = $this->watermarktype == 1 ? @imageCreateFromPNG($watermark_file) : @imageCreateFromGIF($watermark_file);
if (!$watermark_logo) {
return;
}
list($logo_w, $logo_h) = $watermarkinfo;
} else {
//水印是文本类型
$watermarktextcvt = $this->watermarktext['text'];
$box = imagettfbbox($this->watermarktext['size'], $this->watermarktext['angle'], $this->watermarktext['fontpath'], $watermarktextcvt);
$logo_h = max($box[1], $box[3]) - min($box[5], $box[7]);
$logo_w = max($box[2], $box[4]) - min($box[0], $box[6]);
$ax = min($box[0], $box[6]) * -1;
$ay = min($box[5], $box[7]) * -1;
}
$wmwidth = $img_w - $logo_w;
$wmheight = $img_h - $logo_h;
if (($this->watermarktype < 2 && is_readable($watermark_file) || $this->watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif) {
switch ($this->watermarkstatus) {
case 1:
$x = +5;
$y = +5;
break;
case 2:
$x = ($img_w - $logo_w) / 2;
$y = +5;
break;
case 3:
$x = $img_w - $logo_w - 5;
$y = +5;
break;
case 4:
$x = +5;
$y = ($img_h - $logo_h) / 2;
break;
case 5:
$x = ($img_w - $logo_w) / 2;
$y = ($img_h - $logo_h) / 2;
break;
case 6:
$x = $img_w - $logo_w - 5;
$y = ($img_h - $logo_h) / 2;
break;
case 7:
$x = +5;
$y = $img_h - $logo_h - 5;
break;
case 8:
$x = ($img_w - $logo_w) / 2;
$y = $img_h - $logo_h - 5;
break;
case 9:
$x = $img_w - $logo_w - 5;
$y = $img_h - $logo_h - 5;
break;
}
$dst_photo = imagecreatetruecolor($img_w, $img_h);
$target_photo = @$imagecreatefromfunc($this->srcfile);
imageCopy($dst_photo, $target_photo, 0, 0, 0, 0, $img_w, $img_h);
if ($this->watermarktype == 1) {
imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
} elseif ($this->watermarktype == 2) {
if (($this->watermarktext['shadowx'] || $this->watermarktext['shadowy']) && $this->watermarktext['shadowcolor']) {
$shadowcolorrgb = $this->excolor($this->watermarktext['shadowcolor']);
$shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]);
imagettftext($dst_photo, $this->watermarktext['size'], $this->watermarktext['angle'], $x + $ax + $this->watermarktext['shadowx'], $y + $ay + $this->watermarktext['shadowy'], $shadowcolor, $this->watermarktext['fontpath'], $watermarktextcvt);
}
$colorrgb = $this->excolor($this->watermarktext['color']);
$color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]);
imagettftext($dst_photo, $this->watermarktext['size'], $this->watermarktext['angle'], $x + $ax, $y + $ay, $color, $this->watermarktext['fontpath'], $watermarktextcvt);
} else {
imageAlphaBlending($watermark_logo, true);
imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->watermarktrans);
}
if ($this->attachinfo['mime'] == 'image/jpeg') {
$imagefunc($dst_photo, $this->targetfile, $this->watermarkquality);
} else {
$imagefunc($dst_photo, $this->targetfile);
}
} else {
return false;
}
}
return true;
}
示例15: drawPlayer
function drawPlayer($number, $name)
{
$font = "font/tahomab.ttf";
$fontb = "font/tahomab.ttf";
$player = imagecreatetruecolor(46, 46);
// пустое изображение, нужно для прозрачности
$transparent = imagecolorallocatealpha($player, 0, 0, 0, 127);
// устанавливаем прозрачный цвет
imagefill($player, 0, 0, $transparent);
// заполняем им контейнер
imageSaveAlpha($player, true);
// сохраняем прозрачность
imageAlphaBlending($player, true);
// делаем так, чтобы все что копировалось в контейнер, копировалось вместе с настройками прозрачности
$src1 = imagecreatefrompng("img/tshirt.png");
// И копируем нашу форму, в которой этой прозрачности завались
imageCopy($player, $src1, 0, 0, 0, 0, 46, 46);
//копируем картинку с формой в пустую картинку (куда копируем, что копируем, координатаХ бокса, координатаY бокса, координата Х картинки, координата Y картинки, ширина картинки, высота картинки)
$white = imagecolorallocate($player, 255, 255, 255);
// определяем цвет текста - белый
$black = imagecolorallocate($player, 0, 0, 0);
// определяем цвет текста - черный
imageAlphaBlending($player, true);
// А теперь делаем так, чтобы то что будет нарисовано позднее (наложен текст), брало имеющиеся настройки прозрачности.
$nbox = imagettfbbox(10, 0, $fontb, $number);
// определяем размер бокса под номер
$nwidth = $nbox[2] - $nbox[0];
// ширина бокса
$nposition = round(46 / 2 - $nwidth / 2);
imagettftext($player, 10, 0, $nposition, 30, $white, $fontb, $number);
// накладываем номер
$bbox = imagettfbbox(10, 0, $font, $name);
// определяем размер бокса под фамилию
$width = $bbox[2] - $bbox[0];
// ширина бокса
$height = $bbox[1] - $bbox[7];
// высота бокса
$height += 50;
// добавляем 50 пикселей для пиктограммы формы
if ($width < 46) {
$textPosition = round(46 / 2 - $width / 2);
$width = 46;
} else {
$textPosition = 0;
}
// если ширина бокса для текста меньше ширины формы - обрезать не будем. А текст немного сместим.
$box = imagecreatetruecolor($width, $height);
// создаем контейнер под всё
imagefill($box, 0, 0, $transparent);
// заполняем прозрачностью
imageSaveAlpha($box, true);
// созраняем
imageAlphaBlending($box, false);
// копировать сюда будем вместе с настройками
$x = round($width / 2 - 46 / 2);
// позиционируем картинку с формой посередине
imageCopy($box, $player, $x, 0, 0, 0, 46, 46);
//копируем картинку с формой в пустой бокс
//imageAlphaBlending($box, true); //вертаем настройки прозрачности
imagettftext($box, 10, 0, $textPosition, $height - 3, $white, $font, $name);
// накладываем имя-фамилию
return $box;
//возвращаем картинку
}