本文整理汇总了PHP中yii\imagine\Image::text方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::text方法的具体用法?PHP Image::text怎么用?PHP Image::text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\imagine\Image
的用法示例。
在下文中一共展示了Image::text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testText
public function testText()
{
if (!$this->isFontTestSupported()) {
$this->markTestSkipped('Skipping ImageGdTest Gd not installed');
}
$fontFile = Yii::getAlias('@yiiunit/data/imagine/GothamRnd-Light') . '.otf';
$img = Image::text($this->imageFile, 'Yii-2 Image', $fontFile, [0, 0], ['size' => 12, 'color' => '000']);
$img->save($this->runtimeTextFile);
$this->assertTrue(file_exists($this->runtimeTextFile));
}
示例2: actionRegistration
public function actionRegistration()
{
$model = new ContactFormV3();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $model->validate()) {
$newTicketName = Yii::$app->getSecurity()->generateRandomString('16');
$model->number = time();
Image::text(Yii::getAlias('@frontend/web/img/basic/ticket.jpg'), $model->name, Yii::getAlias('@frontend/web/doc/roboto.ttf'), [295, 345], ['color' => '000'])->save(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), ['quality' => 100]);
Image::text(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), $model->email, Yii::getAlias('@frontend/web/doc/roboto.ttf'), [510, 396], ['color' => '000'])->save(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), ['quality' => 100]);
Image::text(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), $model->number, Yii::getAlias('@frontend/web/doc/roboto.ttf'), [428, 33], ['color' => 'fff'])->save(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), ['quality' => 100]);
Image::text(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), $model->number, Yii::getAlias('@frontend/web/doc/roboto.ttf'), [615, 795], ['color' => '000'])->save(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), ['quality' => 100]);
Image::text(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), $model->phone, Yii::getAlias('@frontend/web/doc/roboto.ttf'), [295, 396], ['color' => '000'])->save(Yii::getAlias('@frontend/web/tickets/' . $newTicketName . '.jpg'), ['quality' => 100]);
$model->ticket = $newTicketName . '.jpg';
if ($model->sendEmail(Yii::$app->params['supportEmail'])) {
return 'success';
} else {
return 'Что то пошло не так :( Попробуйте позднее';
}
}
return false;
//throw new NotFoundHttpException('Page not found');
}
示例3: afterFileSave
/**
* After file save
* Generate image thumb, if need.
*/
public function afterFileSave()
{
$images = ['original' => $this->_filePath];
// Thumbnail
$thumb = $this->thumb;
if (isset($thumb['generate']) && $thumb['generate']) {
// Generate thumb image
$images['thumbnail'] = $this->getThumbnailPath($images['original']);
Image::thumbnail($images['original'], $thumb['width'], $thumb['height'])->save($images['thumbnail']);
}
// Add watermark to image
$watermark = $this->watermark;
if (isset($watermark['generate']) && $watermark['generate'] && !empty($watermark['content'])) {
foreach ($images as $image) {
if ($watermark['type'] == 'text') {
Image::text($image, $watermark['content'], __DIR__ . '/simkai.ttf', [10, 10])->save($image);
} elseif ($watermark == 'image' && is_file($watermark['content'])) {
Image::watermark($image, $watermark['content']);
}
}
}
}