Skip to content

Commit

Permalink
Fix blurry preview (#137)
Browse files Browse the repository at this point in the history
* Fix blurry preview

* Update margins
  • Loading branch information
pronskiy authored Jan 3, 2024
1 parent 875e6f8 commit d6b7798
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/src/Seo/SharingImageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

class SharingImageGenerator
{
public const int IMAGE_WIDTH = 1200;
public const int IMAGE_WIDTH = 1600;

public const int IMAGE_HEIGHT = 630;
public const int IMAGE_HEIGHT = 900;

public const int IMAGE_MARGINS = 40;
public const int IMAGE_MARGINS = 72;

public const int TITLE_FONT_SIZE = 40;
public const int TITLE_FONT_SIZE = 72;

public const int AUTHOR_FONT_SIZE = 14;
public const int AUTHOR_FONT_SIZE = 24;

protected bool $inverse = false;

Expand Down Expand Up @@ -72,7 +72,7 @@ protected function prepare(): GdImage

$whiteColor = imagecolorallocate($image, 255, 255, 255);

$title = wordwrap($this->title, 40);
$title = wordwrap($this->title, 27);
$titleBounds = imagettfbbox(
self::TITLE_FONT_SIZE,
0,
Expand Down Expand Up @@ -100,7 +100,7 @@ protected function prepare(): GdImage
self::AUTHOR_FONT_SIZE,
0,
self::IMAGE_MARGINS,
$titleHeight + self::IMAGE_MARGINS * 3 + 10,
self::IMAGE_MARGINS * 3 + $titleHeight + self::AUTHOR_FONT_SIZE,
$whiteColor,
__DIR__.'/../../../assets/fonts/Arial.ttf',
$author
Expand All @@ -113,7 +113,8 @@ protected function prepare(): GdImage
$logo = imagecreatefrompng(__DIR__.'/../../../assets/img/logo_inverse.png');
}

imagecopy($image, $logo, 40, 490, 0, 0, 100, 100);
$src_height = 100;
imagecopy($image, $logo, self::IMAGE_MARGINS, self::IMAGE_HEIGHT-self::IMAGE_MARGINS-$src_height, 0, 0, 100, $src_height);

return $image;
}
Expand Down

0 comments on commit d6b7798

Please sign in to comment.