2017-04-12 74 views
0

我在我的Laravel 5.3中使用Intervention Image進行圖像處理,我想將瓷磚文字水印添加到圖像中。干預圖像:瓷磚文字水印

例如:enter image description here

$img = Image::make(storage_path('app'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.$media->file_path)); 
// use callback to define details 
$width = $img->width(); 
$height = $img->height(); 

     $data = $img->text($watermark, 15, 25, function($font) { 
        $font->file(public_path('../fonts/Xerox Serif Wide.ttf')); 
        $font->size(36); 
        $font->color(array(0,0,0, 0.3)); 
        $font->align('center'); 
        $font->valign('top'); 
        $font->angle(45); 
       }) 

但其不工作它把與角單個行中給出,其中,如我想重複文本,直到它到達圖像的端部。

謝謝。

回答

0

我不知道你是否仍然需要它:)任何方式,我做到了。 但使用戶填充填充的x,y文本和角度之間

$x = 0; 

while ($x < $image->width()) { 
     $y = 0; 

     while($y < $image->height()) { 

     $image->text($watermark->text_text, $x, $y, function($font) use($watermark,$colorhsva,$fontn) { 
        $font->file(public_path('fonts/'.$fontn)); 
        $font->size($watermark->text_font_size); 
        $font->color($colorhsva); 
        $font->align($watermark->text_align); 
        $font->valign($watermark->text_valign); 
        $font->angle($watermark->text_angle); 
       }); 


      $y += $watermark->text_distanceyposition; 
     } 

     $x +=$watermark->text_distancexposition; 
} 

而 TEXT_TEXT = 「用戶文本」

fontn =哪個用戶選擇字體

$ watermark-> text_distanceyposition = ÿ填充形成每個重複

$ watermark-> text_distancexposition = X填充形成每個重複

colorhsva = color array RGBA;

你的情況

$ watermark-> text_angle =角30希望它會幫助你

+0

感謝討伐異教徒艾哈邁德,它作爲魅力的工作。 –