diff --git a/src/OpenGraphImages.php b/src/OpenGraphImages.php index 552465e..ba2fd05 100644 --- a/src/OpenGraphImages.php +++ b/src/OpenGraphImages.php @@ -271,6 +271,16 @@ public function make(string $text, string $preset = 'opengraph'): OpenGraphImage return $this; } + public function makeCustom(string $text, int $width = 1200, int $height = 630): OpenGraphImages + { + $this->imageWidth = $width; + $this->imageHeight = $height; + + $this->createImage($text); + + return $this; + } + public function get(): ?string { return $this->imageBlob; diff --git a/tests/OpenGraphImagesTest.php b/tests/OpenGraphImagesTest.php index 70a90cf..08ac01c 100644 --- a/tests/OpenGraphImagesTest.php +++ b/tests/OpenGraphImagesTest.php @@ -39,6 +39,24 @@ public function testMake(string $text): void } } + /** + * @dataProvider textProvider + */ + public function testMakeCustom(string $text): void + { + $sizesCollection = [ + [500, 500], + [600, 400], + ]; + + foreach ($sizesCollection as $sizes) { + [$width, $height] = $sizes; + $result = $this->openGraphImages->makeCustom($text, $width, $height); + $this->assertInstanceOf(OpenGraphImages::class, $result); + $this->assertEquals('image/png', $this->getMimeTypeFromString($result->get())); + } + } + /** * @dataProvider textProvider */