Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TYPO3在php中向图像添加文本,而不是TS,前端插件_Php_Image_Typo3_Typoscript - Fatal编程技术网

TYPO3在php中向图像添加文本,而不是TS,前端插件

TYPO3在php中向图像添加文本,而不是TS,前端插件,php,image,typo3,typoscript,Php,Image,Typo3,Typoscript,我需要将文本放置在图像顶部并创建缩略图。谷歌地图上有很多标记,上面有数字 根据下面的评论,我可以理解没有addTextToImage,但GIFBUILDER是一个不错的选择。所以我从一位同事那里得到了一些帮助,最终得到了这个效果很好的结果。在此处阅读有关功能和设置的更多信息: 下面的示例使用Google 21x22px的标记。使用png,最终图像以白色背景结束。使用gif创建的图像确实有一个透明的背景组。这可能是服务器设置问题,而不是一般问题 下面是带有简短注释的代码 // create mar

我需要将文本放置在图像顶部并创建缩略图。谷歌地图上有很多标记,上面有数字

根据下面的评论,我可以理解没有addTextToImage,但GIFBUILDER是一个不错的选择。所以我从一位同事那里得到了一些帮助,最终得到了这个效果很好的结果。在此处阅读有关功能和设置的更多信息:

下面的示例使用Google 21x22px的标记。使用png,最终图像以白色背景结束。使用gif创建的图像确实有一个透明的背景组。这可能是服务器设置问题,而不是一般问题

下面是带有简短注释的代码

// create marker
$path = 'fileadmin/templates/matchoffice/images/mapPointer.gif'; // gif on transparent backgroupd. If using a png the background cannot be made transparent
$cObj = t3lib_div::makeInstance('tslib_cObj');
$counter = $gmapsElementCounter; // the number that will be written on each marker

$imgTSConfigThumb['file'] = 'GIFBUILDER';
$imgTSConfigThumb['file.']['XY'] = '21,22'; // size of final image. In this case same as input file size
$imgTSConfigThumb['file.']['format'] = 'png';
$imgTSConfigThumb['file.']['backColor'] = '#ffffff'; // we want it transparent. That is done in next line
$imgTSConfigThumb['file.']['transparentColor'] = '#ffffff'; // this color to be transparent.... workaround
$imgTSConfigThumb['file.']['10'] = 'IMAGE';
$imgTSConfigThumb['file.']['10.']['file'] = $path;
$imgTSConfigThumb['file.']['10.']['file.']['maxW'] = 21; // just setting them to the size of the input pig
$imgTSConfigThumb['file.']['10.']['file.']['maxH'] = 22; // just setting them to the size of the input pig
$imgTSConfigThumb['file.']['10.']['align'] = 'c,c'; // center this layer (left/right))
$imgTSConfigThumb['file.']['20'] = 'TEXT';
$imgTSConfigThumb['file.']['20.']['text'] = $counter; // use counter as text
$imgTSConfigThumb['file.']['20.']['fontFile'] = 'fileadmin/templates/matchoffice/fonts/arial.ttf'; // font for text
$imgTSConfigThumb['file.']['20.']['align'] = 'center'; // center (left/right)
$imgTSConfigThumb['file.']['20.']['offset'] = '0,12'; // move it 0pz to the left and 12px down
$imgTSConfigThumb['file.']['20.']['fontColor'] = 'white'; // text color white
$imgTSConfigThumb['file.']['20.']['fontSize'] = '9';
$imgTSConfigThumb['file.']['20.']['niceText'] = '1'; // don't know, but it did improve the text

$thumbpath = $this->cObj->IMG_RESOURCE($imgTSConfigThumb);

问题已结束-在此之前,更新为有效的最终解决方案


在向图像添加文本时,GIFBUILDER似乎是一种方法。如果您需要做同样的事情,请使用abouve代码。

好吧,代码似乎很好,它基本上按照您所说的那样工作,那么到底是什么问题?什么格式不对,你期望什么?另外,您确定问题的根源不仅仅是第二行对$path变量的重新定义吗?您似乎正在使用已经生成的图像作为源首先:我以前从未这样做过,如果有更简单的方法来做,我会犹豫。第二,我还没有找到一个好的例子,文档很难理解。再加上我的gif,对不起,png远远不能在客户网站上使用。。所以我希望有人曾经尝试过用文本覆盖来创建图标,并与大家分享。或者分享一个关于它的优秀教程的链接。我认为core_api很难遵循。