Skip to content

OpenGraph

Jan Hermann edited this page Oct 9, 2026 · 1 revision

📣

Images in the 1.91:1 ratio for Open Graph.

Class Imagony\OpenGraph\Image for converting images to the 1.91:1 ratio used by social networks.

convert

convert(string $source, string $destination, string $fallback): string

  • Returns $destination when it exists already.
  • Landscape images are cropped (EXACT) to the 1.91:1 ratio.
  • Other images are placed in the centre of a white 1.91:1 canvas.
  • If $source does not exist, $fallback is converted instead. When the image can not be read or saved, the path $fallback is returned.
use Imagony\OpenGraph\Image;

$path = (new Image())->convert(
    "/var/www/public/images/article.jpg",
    "/var/www/public/og/article.jpg",
    "/var/www/public/images/no-image.png"
);

Clone this wiki locally