Saving images | image | Spatie

 SPATIE

  Image
========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Image](https://spatie.be/docs/image/v2)  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)

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

Usage
-----

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

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

- [ Overview ](https://spatie.be/docs/image/v2/image-manipulations/overview)
- [ Resizing images ](https://spatie.be/docs/image/v2/image-manipulations/resizing-images)
- [ Optimizing images ](https://spatie.be/docs/image/v2/image-manipulations/optimizing-images)
- [ Adjustments ](https://spatie.be/docs/image/v2/image-manipulations/adjustments)
- [ Image canvas ](https://spatie.be/docs/image/v2/image-manipulations/image-canvas)
- [ Effects ](https://spatie.be/docs/image/v2/image-manipulations/effects)
- [ Watermarks ](https://spatie.be/docs/image/v2/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`, `FORMAT_WEBP` and `FORMAT_TIFF`.

```
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)

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
