Saving images | image | Spatie

 SPATIE

  Image
========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Image](https://spatie.be/docs/image/v1)  Usage  Saving images

 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/v1/introduction)
- [ Postcardware ](https://spatie.be/docs/image/v1/postcardware)
- [ Installation and setup ](https://spatie.be/docs/image/v1/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/image/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/image/v1/changelog)
- [ About us ](https://spatie.be/docs/image/v1/about-us)

Usage
-----

- [ Basic usage ](https://spatie.be/docs/image/v1/usage/basic-usage)
- [ Saving images ](https://spatie.be/docs/image/v1/usage/saving-images)
- [ Retrieving properties ](https://spatie.be/docs/image/v1/usage/retrieving-properties)
- [ Preparing manipulations ](https://spatie.be/docs/image/v1/usage/preparing-manipulations)
- [ Advanced manipulations ](https://spatie.be/docs/image/v1/usage/advanced-manipulations)

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

- [ Overview ](https://spatie.be/docs/image/v1/image-manipulations/overview)
- [ Resizing images ](https://spatie.be/docs/image/v1/image-manipulations/resizing-images)
- [ Optimizing images ](https://spatie.be/docs/image/v1/image-manipulations/optimizing-images)
- [ Adjustments ](https://spatie.be/docs/image/v1/image-manipulations/adjustments)
- [ Image canvas ](https://spatie.be/docs/image/v1/image-manipulations/image-canvas)
- [ Effects ](https://spatie.be/docs/image/v1/image-manipulations/effects)
- [ Watermarks ](https://spatie.be/docs/image/v1/image-manipulations/watermarks)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/image                                                                                                                                                                                                                                    `

Saving images
=============

###  On this page

1. [ Saving in a different image format ](#content-saving-in-a-different-image-format)
2. [ Changing JPEG quality ](#content-changing-jpeg-quality)

By default calling the `save` method on the `Image` will apply all manipulations to your original image file.

```
Image::load('example.jpg')
    ->sepia()
    ->save();
```

To save the image as a copy in a new location pass in the optional `$outputPath`.

```
Image::load('example.jpg')
    ->sepia()
    ->save('sepia-example.jpg');
```

Saving in a different image format
--------------------------------------------------------------------------------------------------------------------------------------------------------------

To save your image as a different image format call the `format` method and pass in the desired format. Currently the following formats are supported: `FORMAT_JPG`, `FORMAT_PJPG`, `FORMAT_PNG`, `FORMAT_GIF` and `FORMAT_WEBP`.

```
Image::load('example.jpg')
    ->format(Manipulations::FORMAT_PNG)
    ->save('example.png');
```

Alternatively you can change the image format by saving the image with a different file extension than the original image. The `Image` package will then attempt to convert the image to the correct image format.

```
Image::load('example.jpg')
    ->save('converted-example.png'); // Will convert the original image to PNG
```

Changing JPEG quality
-----------------------------------------------------------------------------------------------------------------------

By calling the `quality` method on the `Image` you can specify the JPEG quality in percent. This only applies to saving JPEG files.

The `$quality` argument should be an integer ranging from `0` to `100`.

```
Image::load('example.jpg')
    ->quality(20)
    ->save();
```

![JPEG quality lowered](../images/example-quality.jpg)
