Upgrading | image | Spatie

 SPATIE

  Image
========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Image](https://spatie.be/docs/image/v3)  Upgrading

 Version   v3   v2   v1

 Other versions for crawler [v3](https://spatie.be/docs/image/v3) [v2](https://spatie.be/docs/image/v2) [v1](https://spatie.be/docs/image/v1)

- [ Introduction ](https://spatie.be/docs/image/v3/introduction)
- [ Postcardware ](https://spatie.be/docs/image/v3/postcardware)
- [ Installation and setup ](https://spatie.be/docs/image/v3/installation-and-setup)
- [ Supported formats ](https://spatie.be/docs/image/v3/formats)
- [ Questions &amp; issues ](https://spatie.be/docs/image/v3/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/image/v3/changelog)
- [ About us ](https://spatie.be/docs/image/v3/about-us)
- [ Upgrading ](https://spatie.be/docs/image/v3/upgrading)

Usage
-----

- [ Basic usage ](https://spatie.be/docs/image/v3/usage/basic-usage)
- [ Saving images ](https://spatie.be/docs/image/v3/usage/saving-images)
- [ Retrieving properties ](https://spatie.be/docs/image/v3/usage/retrieving-properties)
- [ Colors ](https://spatie.be/docs/image/v3/usage/colors)

Image manipulations
-------------------

- [ Overview ](https://spatie.be/docs/image/v3/image-manipulations/overview)
- [ Resizing images ](https://spatie.be/docs/image/v3/image-manipulations/resizing-images)
- [ Optimizing images ](https://spatie.be/docs/image/v3/image-manipulations/optimizing-images)
- [ Adjustments ](https://spatie.be/docs/image/v3/image-manipulations/adjustments)
- [ Image canvas ](https://spatie.be/docs/image/v3/image-manipulations/image-canvas)
- [ Effects ](https://spatie.be/docs/image/v3/image-manipulations/effects)
- [ Adding a watermark ](https://spatie.be/docs/image/v3/image-manipulations/adding-a-watermark)
- [ Adding text ](https://spatie.be/docs/image/v3/image-manipulations/text)

 Upgrading
=========

###  On this page

1. [ Working with the Image object. ](#content-working-with-the-image-object)
2. [ Other changes ](#content-other-changes)

v2 to v3
================================================================================

V3 is a major rewrite where we removed several dependencies and tried to streamline all manipulations.

Note that some results might be slightly different from previous versions as we made improvement across a number of methods.

Working with the Image object.
------------------------------------------------------------------------------------------------------------------------------------------------

The `Image` class has been slimmed down to only being responsible for initializing and delegating to the correct driver (GD or Imagick).

As of V3 there are 3 ways to create a new image instance:

```
// 1. By passing the path to the image in the constructor.
$image = new Image('path/to/image.jpg');

// 2. Using the static load method.
$image = Image::load('path/to/image.jpg');

// 3. Selecting a driver and then loading the image.
$image = Image::useImageDriver(ImageDriver::Imagick)->load('path/to/image.jpg');
```

Other changes
-----------------------------------------------------------------------------------------------

- The option to create a manipulations instance has been removed.
- The `apply` method has been removed.
- Calling a manipulation method multiple times will now apply all manipulations.
- The `border` method now accepts a BorderType enum value, and it's parameters have been reordered.
- The `orientation` method now accepts a Orientation enum value.
- The `flip` method now accepts a FlipDirection enum value.
- The `fit` method now accepts a Fit enum value.
- The `crop` method now accepts a CropPosition enum value.
- The `focalCrop` method has the $zoom parameter removed.
- The `watermark` method has been renamed to the `insert` method and accepts additional parameters.
- v `watermarkOpacity`, `watermarkPadding`, `watermarkHeight` and `watermarkWidth` methods have been removed.
