Skip to content

Commit

Permalink
Merge pull request #280 from PrabalPradhan1991/patch-1
Browse files Browse the repository at this point in the history
## Correction on Selecting a driver example

- using the previous command
```php
Image::useImageDriver(ImageDriver::Gd)->loadFile(string $pathToImage);
```
gave me following errors 
1. Non static method 'useImageDriver' should not be called statically.
2. Undefined method 'loadFile'
3. undefinedType ImageDriver
  • Loading branch information
freekmurze authored Dec 11, 2024
2 parents 96e14fc + 6594ad8 commit 2fb420a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/usage/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ 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);
```

Expand All @@ -16,14 +18,19 @@ $image = Image::load(string $pathToImage);
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
$image = Image::useImageDriver(ImageDriver::Gd)->loadFile(string $pathToImage);
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](/docs/image/v3/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)
Expand All @@ -35,6 +42,8 @@ Image::load('example.jpg')
Every manipulation you call will be applied. When calling a manipulation method multiple times each call will be applied immediately.

```php
use Spatie\Image\Image;

// This will lower the brightness first by 40% and then by 20%
Image::load('example.jpg')
->brightness(-40)
Expand All @@ -48,6 +57,8 @@ Image::load('example.jpg')
Calling the `save` method on an `Image` will save the modifications to the specified file.

```php
use Spatie\Image\Image;

Image::load('example.jpg')
->width(50)
->save('modified-example.jpg');
Expand All @@ -60,6 +71,8 @@ To save the image in a different image format or with a different jpeg quality [
Calling the `base64` method on an `Image` will return a base64 string of the image.

```php
use Spatie\Image\Image;

Image::load('example.jpg')
->base64();
```
Expand Down

0 comments on commit 2fb420a

Please sign in to comment.