Created
March 23, 2020 09:49
-
-
Save themsaid/713d938de53a0ed31c73700c0d3a5564 to your computer and use it in GitHub Desktop.
Revisions
-
themsaid revised this gist
Mar 23, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ require `"stil/gd-text": "^1.1",` ```php class ControllerClass extends Controller { public function __invoke($slug) -
themsaid created this gist
Mar 23, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ require `"stil/gd-text": "^1.1",` ``` class ControllerClass extends Controller { public function __invoke($slug) { $post = WinkPost::where('slug', $slug)->first(); $quickDip = $post->tags()->whereSlug('quick-dip')->first() ; $border = 40; $image = imagecreatetruecolor(1200, 630); $backgroundColor = imagecolorallocate($image, 1, 22, 39); imagefill($image, 0, 0, $backgroundColor); $box = new Box($image); // Diving Laravel $box->setFontFace( resource_path('fonts/Roboto-Light.ttf') ); $box->setFontColor(new Color(255, 255, 255)); $box->setTextShadow(new Color(0, 0, 0, 50), 2, 2); $box->setFontSize(40); $box->setBox($border, $border, 1200 - $border - $border, 630 - $border - $border); $box->setTextAlign('left', 'top'); $box->draw('Diving Laravel'.($quickDip ? ' - Quick Dip' : '')); // Title $box->setFontFace( resource_path('fonts/Roboto-Black.ttf') ); $box->setFontColor( $quickDip ? new Color(228, 64, 54) : new Color(255, 255, 255) ); $box->setFontSize(60); $box->setBox($border, $border + 130, 1200 - $border - $border, 630 - 120 - $border); $box->draw($post->title); // Update Date $box->setFontFace( resource_path('fonts/Roboto-Light.ttf') ); $box->setFontColor(new Color(153, 182, 210)); $box->setFontSize(35); $box->setBox($border, 630 - $border - 38*1.3, 1200 - $border - $border, 630 - $border - $border); if ($quickDip) { $box->draw('60 sec read - by Mohamed Said'); } else { $box->draw(ReadingTimeCounter::generate(strip_tags($post->body)).' read - by Mohamed Said'); } header("Content-type: image/png"); imagepng($image); } } ```