From 289c631d6175ed1dd7505d1b8e056d0cbcf4c165 Mon Sep 17 00:00:00 2001 From: Prabal Pradhan Date: Wed, 11 Dec 2024 16:24:02 +0545 Subject: [PATCH] Update basic-usage.md Adds a section "Selecting a driver" --- docs/usage/basic-usage.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/usage/basic-usage.md b/docs/usage/basic-usage.md index f00daa99..d46a94ed 100644 --- a/docs/usage/basic-usage.md +++ b/docs/usage/basic-usage.md @@ -8,14 +8,31 @@ weight: 1 Load an image by calling the static `load` method on the `Image` and passing in the `$pathToImage`. ```php +use Spatie\Image\Image; + $image = Image::load(string $pathToImage); ``` + +## Selecting a driver + +By default, the Imagick driver will be used. However if you would like to use GD you can do this by selecting the driver before loading the image. + +```php +use Spatie\Image\Image; + +$image = Image::load($file)->useImageDriver('imagick'); // for imagick +$image = Image::load($file)->useImageDriver('gd'); // for gd +``` + + ## Applying manipulations Any of the [image manipulations](/image/v1/image-manipulations/overview) can be applied to the loaded `Image` by calling the manipulation's method. All image manipulation methods can be chained. ```php +use Spatie\Image\Image; + Image::load('example.jpg') ->sepia() ->blur(50) @@ -29,6 +46,8 @@ Image::load('example.jpg') Calling the `save` method on an `Image` will save the modifications to the original file. You can save your modified image by passing a `$outputPath` to the `save` method. ```php +use Spatie\Image\Image; + Image::load('example.jpg') ->width(50) ->save('modified-example.jpg');