當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::text方法代碼示例

本文整理匯總了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));
 }
開發者ID:glcode,項目名稱:yii2-2.0.3-annotated,代碼行數:10,代碼來源:AbstractImageTest.php

示例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');
 }
開發者ID:sergey-exu,項目名稱:myhome,代碼行數:21,代碼來源:SiteController.php

示例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']);
             }
         }
     }
 }
開發者ID:hiscaler,項目名稱:yii2-file-upload-behaviors,代碼行數:26,代碼來源:ImageUploadBehavior.php


注:本文中的yii\imagine\Image::text方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。