diff --git a/.gitignore b/.gitignore index a6197de..1172c3d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /node_modules /phpunit.xml /.phpunit.cache + +.idea/ diff --git a/README.md b/README.md index ca3b83a..6fbdc71 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,10 @@ The default theme is `Light`. You can set the theme on your image at any point before it's rendered: ```php +use SimonHamp\TheOg\Themes\Themes; + $image = new Image; -$image->theme(Theme::Dark); +$image->theme(Themes::Dark); ``` #### Creating themes @@ -105,6 +107,25 @@ There are currently 2 layouts: `Standard` and `GitHubBasic`. `Standard` is the d More layouts are coming. +### Storing the image elsewhere + +If you prefer to store your image somewhere other than the local filesystem (e.g. storing it on Amazon S3) you can use the `toString()` method. + +`toString()` will return the rendered image as a binary string: + +```php +$image = (new Image())->toString(); + +// $service here could be an AWS\S3\S3Client, for example +$service->putObject([ + 'Key' => 'example-image.png', + 'Body' => $image, + 'ContentType' => 'image/png', +]); +``` + +This will send the raw binary data directly to the external service without needing to write the image to a file on the local disk first. + ## Testing The OG uses [snapshot testing](https://github.com/spatie/phpunit-snapshot-assertions). To run the integration tests,