├── .github └── FUNDING.yml ├── .gitignore ├── httpauth ├── readme.md ├── v4 │ ├── api │ │ ├── authenticator.md │ │ └── readme.md │ ├── getting-started │ │ ├── installation.md │ │ ├── introduction.md │ │ └── readme.md │ └── readme.md └── v5 │ ├── api │ ├── authenticator.md │ └── readme.md │ ├── getting-started │ ├── installation.md │ ├── introduction.md │ └── readme.md │ └── readme.md ├── image ├── readme.md ├── v2 │ ├── api │ │ ├── backup.md │ │ ├── base-path.md │ │ ├── blur.md │ │ ├── brightness.md │ │ ├── cache.md │ │ ├── canvas.md │ │ ├── circle.md │ │ ├── colorize.md │ │ ├── contrast.md │ │ ├── crop.md │ │ ├── destroy.md │ │ ├── ellipse.md │ │ ├── encode.md │ │ ├── exif.md │ │ ├── filesize.md │ │ ├── fill.md │ │ ├── filter.md │ │ ├── fit.md │ │ ├── flip.md │ │ ├── gamma.md │ │ ├── get-core.md │ │ ├── greyscale.md │ │ ├── height.md │ │ ├── heighten.md │ │ ├── insert.md │ │ ├── interlace.md │ │ ├── invert.md │ │ ├── iptc.md │ │ ├── limit-colors.md │ │ ├── line.md │ │ ├── make.md │ │ ├── mask.md │ │ ├── mime.md │ │ ├── opacity.md │ │ ├── orientate.md │ │ ├── pick-color.md │ │ ├── pixel.md │ │ ├── pixelate.md │ │ ├── polygon.md │ │ ├── psr-response.md │ │ ├── readme.md │ │ ├── rectangle.md │ │ ├── reset.md │ │ ├── resize-canvas.md │ │ ├── resize.md │ │ ├── response.md │ │ ├── rotate.md │ │ ├── save.md │ │ ├── sharpen.md │ │ ├── stream.md │ │ ├── text.md │ │ ├── trim.md │ │ ├── widen.md │ │ └── width.md │ ├── getting-started │ │ ├── configuration.md │ │ ├── formats.md │ │ ├── installation.md │ │ ├── introduction.md │ │ ├── readme.md │ │ ├── release-notes.md │ │ └── upgrade.md │ ├── readme.md │ └── usage │ │ ├── cache.md │ │ ├── filters.md │ │ ├── http-response.md │ │ ├── overview.md │ │ ├── readme.md │ │ ├── uploads.md │ │ └── url-manipulation.md └── v3 │ ├── basics │ ├── colors.md │ ├── configuration-drivers.md │ ├── image-output.md │ ├── instantiation.md │ ├── meta-information.md │ └── readme.md │ ├── getting-started │ ├── formats.md │ ├── frameworks.md │ ├── installation.md │ ├── introduction.md │ ├── readme.md │ └── upgrade.md │ ├── modifying-images │ ├── advanced.md │ ├── animations.md │ ├── custom-modifiers.md │ ├── drawing.md │ ├── effects.md │ ├── inserting.md │ ├── readme.md │ ├── resizing.md │ └── text-fonts.md │ └── readme.md ├── readme.md ├── validation ├── readme.md ├── v3 │ ├── introduction │ │ ├── installation.md │ │ ├── introduction.md │ │ ├── readme.md │ │ └── usage.md │ ├── readme.md │ └── rules │ │ ├── base64.md │ │ ├── bic.md │ │ ├── camelcase.md │ │ ├── cidr.md │ │ ├── creditcard.md │ │ ├── data-uri-scheme.md │ │ ├── domain.md │ │ ├── ean.md │ │ ├── gtin.md │ │ ├── hex-color.md │ │ ├── html-clean.md │ │ ├── iban.md │ │ ├── imei.md │ │ ├── isbn.md │ │ ├── isin.md │ │ ├── issn.md │ │ ├── jwt.md │ │ ├── kebab-case.md │ │ ├── lower-case.md │ │ ├── luhn.md │ │ ├── mime-type.md │ │ ├── postal-code.md │ │ ├── readme.md │ │ ├── semver.md │ │ ├── slug.md │ │ ├── snake-case.md │ │ ├── title-case.md │ │ ├── ulid.md │ │ ├── upper-case.md │ │ └── username.md └── v4 │ ├── introduction │ ├── introduction.md │ └── readme.md │ ├── readme.md │ └── rules │ ├── austrian-insurance-number.md │ ├── base64.md │ ├── bic.md │ ├── camelcase.md │ ├── cidr.md │ ├── creditcard.md │ ├── data-uri-scheme.md │ ├── domain.md │ ├── ean.md │ ├── grid.md │ ├── gtin.md │ ├── hex-color.md │ ├── html-clean.md │ ├── iban.md │ ├── imei.md │ ├── isbn.md │ ├── isin.md │ ├── isrc.md │ ├── issn.md │ ├── jwt.md │ ├── kebab-case.md │ ├── lower-case.md │ ├── luhn.md │ ├── mime-type.md │ ├── postal-code.md │ ├── readme.md │ ├── semver.md │ ├── slug.md │ ├── snake-case.md │ ├── title-case.md │ ├── ulid.md │ ├── upper-case.md │ └── username.md └── zodiac ├── readme.md ├── v3 ├── api │ ├── calculator.md │ ├── readme.md │ └── zodiac.md ├── introduction │ ├── installation.md │ ├── introduction.md │ ├── readme.md │ └── usage.md └── readme.md ├── v4 ├── api │ ├── calculator.md │ ├── readme.md │ └── zodiac.md ├── introduction │ ├── installation.md │ ├── introduction.md │ ├── readme.md │ └── usage.md └── readme.md └── v5 ├── api ├── calculator.md ├── readme.md └── zodiac.md ├── introduction ├── installation.md ├── introduction.md ├── readme.md └── usage.md └── readme.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [Intervention] 2 | ko_fi: interventionphp 3 | custom: https://paypal.me/interventionio 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /httpauth/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | sort: 3 3 | label: "HttpAuth" 4 | title: "Intervention HttpAuth" 5 | subtitle: "HTTP Authentication Management" 6 | description: "Intervention HttpAuth is a library to manage HTTP Basic and Digest authentication." 7 | package: "intervention/httpauth" 8 | repository_url: "https://github.com/Intervention/httpauth" 9 | license: "MIT" 10 | keywords: 11 | - php 12 | - authentication 13 | - "basic auth" 14 | - "digest auth" 15 | --- 16 | -------------------------------------------------------------------------------- /httpauth/v4/api/authenticator.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Authenticator" 3 | subtitle: "Using the HTTP Authenticator" 4 | --- 5 | 6 | [TOC] 7 | 8 | ## Creating the Authenticator 9 | 10 | The workflow is easy. Just create an authenticator in the first step and secure your resource by checking for credentials with a second step. 11 | 12 | I strongly recommend using a library like [PHP dotenv](https://github.com/vlucas/phpdotenv) to store the credentials and keep usernames and passwords out of version control. 13 | 14 | ### Using the Class Constructor 15 | 16 | ```php 17 | use Intervention\HttpAuth\Authenticator; 18 | 19 | $auth = new Authenticator( 20 | 'basic', // auth type 21 | 'Secure Resource', // name of realm 22 | 'admin', // username 23 | 'secret' // password 24 | ); 25 | ``` 26 | 27 | Alternatively use methods to set properties. 28 | 29 | ```php 30 | use Intervention\HttpAuth\Authenticator; 31 | 32 | $auth = new Authenticator(); 33 | $auth->withType('digest'); 34 | $auth->withRealm('Secure'); 35 | $auth->withCredentials('admin', 'secret'); 36 | ``` 37 | 38 | ### Using Static Factory Methods 39 | 40 | The package comes with several static factory methods to create the authenticator. 41 | 42 | ```php 43 | use Intervention\HttpAuth\Authenticator; 44 | 45 | // create basic auth by array 46 | $auth = Authenticator::make([ 47 | 'type' => 'basic', 48 | 'realm' => 'Secure Resource', 49 | 'username' => 'admin', 50 | 'password' => 'secret', 51 | ]); 52 | ``` 53 | 54 | Or create an authenticator by defining the authentication type directly. 55 | 56 | ```php 57 | use Intervention\HttpAuth\Authenticator; 58 | 59 | // create basic auth instance 60 | $auth = Authenticator::basic('Secured Realm')->withCredentials('admin', 'secret'); 61 | 62 | // create digest authenticator 63 | $auth = Authenticator::digest('Secured Realm')->withCredentials('admin', 'secret'); 64 | ``` 65 | 66 | ## Securing the Resource 67 | 68 | After you created a HTTP authenticator instance, you have to call `secure()` to secure the resource by checking for credentials. Otherwise nothing will happen. 69 | 70 | The server will send a HTTP response with the status code 401 and the browser will ask the user for a username and a password. 71 | 72 | 73 | ```php 74 | use Intervention\HttpAuth\Authenticator; 75 | 76 | // creating authenticator and checking credentials 77 | Authenticator::make()->withCredentials('admin', 'secret')->secure(); 78 | ``` 79 | 80 | ### Customizing Notice 81 | 82 | Optionally you can provide a status message, which will be displayed to the user, when the credential check failed. 83 | 84 | ```php 85 | use Intervention\HttpAuth\Authenticator; 86 | 87 | // proving custom message for users with failed credential check 88 | Authenticator::basic()->secure('Sorry, no access.'); 89 | ``` 90 | -------------------------------------------------------------------------------- /httpauth/v4/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /httpauth/v4/getting-started/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | sort: 0 5 | --- 6 | 7 | You can install this package quickly and easily with Composer. 8 | 9 | Require the package via Composer: 10 | 11 | ```bash 12 | composer require intervention/httpauth 13 | ``` 14 | 15 | After the installation you can start [using the authenticator](/v4/api/authenticator). 16 | -------------------------------------------------------------------------------- /httpauth/v4/getting-started/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention HttpAuth" 3 | label: "Introduction" 4 | subtitle: "HTTP Authentication Management" 5 | sort: 0 6 | --- 7 | 8 | Intervention HttpAuth is a library to manage HTTP basic & digest authentication. 9 | 10 | ### Code Example 11 | 12 | The handling is easy. You just have to create an authenticator with your desired settings and call the `secure()` method to check for given credentials 13 | 14 | ```php 15 | use Intervention\HttpAuth\Authenticator; 16 | 17 | // create authenticator 18 | $auth = new Authenticator(); 19 | $auth->withType('digest'); 20 | $auth->withRealm('Secure Realm'); 21 | $auth->withCredentials('admin', 'secret'); 22 | 23 | // check for credentials 24 | $auth->secure(); 25 | ``` 26 | 27 | The library comes with several static factory methods to create the authenticator. 28 | 29 | ```php 30 | use Intervention\HttpAuth\Authenticator; 31 | 32 | // create by array 33 | $auth = Authenticator::make([ 34 | 'type' => 'basic', 35 | 'realm' => 'Secure Resource', 36 | 'username' => 'admin', 37 | 'password' => 'secret', 38 | ]); 39 | ``` 40 | 41 | Read more on how to [install](/v4/getting-started/installation) or [use the package](/v4/api/authenticator) 42 | -------------------------------------------------------------------------------- /httpauth/v4/getting-started/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /httpauth/v4/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 4" 3 | status: "eol" 4 | --- 5 | -------------------------------------------------------------------------------- /httpauth/v5/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /httpauth/v5/getting-started/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | lead: "Learn how to install Intervention HttpAuth for PHP with Composer and discover how to configure your web server to make the library work perfectly." 5 | sort: 1 6 | --- 7 | 8 | [TOC] 9 | 10 | ## Server Requirements 11 | 12 | Before you begin with the installation make sure that your server environment 13 | supports the following requirements. 14 | 15 | - PHP >= 8.2 16 | 17 | ## Installation 18 | 19 | You can install this package quickly and easily with [Composer](https://getcomposer.org/). 20 | 21 | Require the package via Composer: 22 | 23 | ```bash 24 | composer require intervention/httpauth 25 | ``` 26 | 27 | After the installation you can start [using the authenticator](/v5/api/authenticator). 28 | 29 | ## Server Configuration 30 | 31 | Although the configuration of the HTTP server should usually already be set 32 | correctly, in rare cases it may be necessary to make adjustments. 33 | 34 | ### Apache 35 | 36 | If you are using Apache and running PHP with CGI/FastCGI, check the server 37 | configuration to make sure the [authorization headers are passed correctly to 38 | PHP](https://support.deskpro.com/en/kb/articles/missing-authorization-headers-with-apache). 39 | -------------------------------------------------------------------------------- /httpauth/v5/getting-started/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "Introduction" 3 | title: "Intervention HttpAuth" 4 | subtitle: "HTTP Authentication Management" 5 | lead: "Intervention HttpAuth is a PHP library for authenticating resources using HTTP Basic or Digest authentication. Learn how to install and configure the package correctly." 6 | sort: 0 7 | --- 8 | 9 | The package [can be easily installed](/v5/getting-started/installation) and 10 | provides an API that makes these steps as simple as possible. 11 | 12 | The workflow is divided into two steps. In the first, an instance of the 13 | `Authenticator::class` class is created descided which type of authentication 14 | should be used. In the second step, the respective resource is secured by a 15 | single call. 16 | 17 | ### 1. Create Authenticator Instance 18 | 19 | To create authenticator instances you can choose between basic & digest auth. 20 | Simply use the static helper methods described below or [learn how to 21 | instantiate](/v5/api/authenticator) the authenticator in other ways. 22 | 23 | #### Create Authenticator Using HTTP Basic Auth 24 | 25 | ```php 26 | use Intervention\HttpAuth\Authenticator; 27 | 28 | // create http basic auth 29 | $auth = Authenticator::basic( 30 | 'myUsername', 31 | 'myPassword', 32 | ); 33 | ``` 34 | 35 | #### Create Authenticator Using HTTP Digest Auth 36 | 37 | ```php 38 | use Intervention\HttpAuth\Authenticator; 39 | 40 | // create http digest auth 41 | $auth = Authenticator::digest( 42 | 'myUsername', 43 | 'myPassword', 44 | ); 45 | ``` 46 | 47 | ### 2. Ask User for Credentials 48 | 49 | After you created a HTTP authentication instance, you have to call `secure()` 50 | to secure the resource. This results in a 401 HTTP response and the browser 51 | asking for credentials. 52 | 53 | ```php 54 | $auth->secure(); 55 | ``` 56 | 57 | A character string can optionally be passed to the method. This is displayed if 58 | authentication fails. Output from template engines can also be used here. 59 | 60 | ```php 61 | $auth->secure('Sorry, you can not access this resource!'); 62 | ``` 63 | 64 | Read more on how to [install](/v5/getting-started/installation) or [use the package](/v5/api/authenticator). 65 | -------------------------------------------------------------------------------- /httpauth/v5/getting-started/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /httpauth/v5/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 5" 3 | status: "stable" 4 | --- 5 | -------------------------------------------------------------------------------- /image/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | sort: 0 3 | label: "Image" 4 | title: "Intervention Image" 5 | subtitle: "PHP Image Processing" 6 | description: "Intervention Image is a PHP image processing library that provides a simple and expressive way to create, edit, and compose images. It provides an universal API for the most popular PHP image manipulation extensions." 7 | package: "intervention/image" 8 | repository_url: "https://github.com/Intervention/image" 9 | license: "MIT" 10 | keywords: 11 | - php 12 | - image 13 | - image-processing 14 | - gd 15 | - imagick 16 | --- 17 | -------------------------------------------------------------------------------- /image/v2/api/backup.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "backup()" 3 | title: "Image::backup" 4 | subtitle: "Save a backup of the current image state" 5 | --- 6 | 7 | > public Intervention\Image\Image backup([string $name]) 8 | 9 | Backups current image state as fallback for [reset method](/v2/api/reset) under an optional **name**. Overwrites older state on every call, unless a different name is passed. 10 | 11 | ### Parameters 12 | 13 | #### name (optional) 14 | The name of the backup in memory. Default: *default* 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create empty canvas with black background 23 | $img = Image::canvas(120, 90, '#000000'); 24 | 25 | // fill image with color 26 | $img->fill('#b53717'); 27 | 28 | // backup image with colored background 29 | $img->backup(); 30 | 31 | // fill image with tiled image 32 | $img->fill('tile.png'); 33 | 34 | // return to colored background 35 | $img->reset(); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [reset](/v2/api/reset) 41 | -------------------------------------------------------------------------------- /image/v2/api/base-path.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "basePath()" 3 | title: "Image::basePath" 4 | subtitle: "Get fully qualified path" 5 | --- 6 | 7 | > public Intervention\Image\Image basePath() 8 | 9 | Get the base path for the current image, if instance was initiated from an actual file. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | 17 | Returns the absolute path of the image file as `string` or `null` if the image instance wasn't created from a file. 18 | 19 | Examples 20 | 21 | ```php 22 | // create an image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // get file path 26 | $path = $img->basePath(); 27 | ``` 28 | -------------------------------------------------------------------------------- /image/v2/api/blur.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "blur()" 3 | title: "Image::blur" 4 | subtitle: "Apply a gaussian blur filter with a optional amount on the current image." 5 | --- 6 | 7 | > public Intervention\Image\Image blur([integer $amount]) 8 | 9 | **Note: Performance intensive on larger amounts of blur with GD driver. Use with care.** 10 | 11 | ### Parameters 12 | 13 | #### amount (optional) 14 | The amount of the blur strength. Use values between `0` and `100`. Default: `1` 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // apply slight blur filter 26 | $img->blur(); 27 | 28 | // apply stronger blur 29 | $img->blur(15); 30 | ``` 31 | 32 | ### See also 33 | 34 | - [sharpen](/v2/api/sharpen) 35 | - [pixelate](/v2/api/pixelate) 36 | - [brightness](/v2/api/brightness) 37 | - [contrast](/v2/api/contrast) 38 | -------------------------------------------------------------------------------- /image/v2/api/brightness.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "brightness()" 3 | title: "Image::brightness" 4 | subtitle: "Change the brightness of an image" 5 | --- 6 | 7 | > public Intervention\Image\Image brightness(integer $level) 8 | 9 | Changes the brightness of the current image by the given **level**. Use values between ```-100``` for min. brightness ```0``` for no change and ```+100``` for max. brightness. 10 | 11 | ### Parameters 12 | 13 | #### level 14 | Level of brightness change applied to the current image. Use values between `-100` and `+100`. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // increase brightness of image 26 | $img->brightness(35); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [contrast](/v2/api/contrast) 32 | - [gamma](/v2/api/gamma) 33 | - [colorize](/v2/api/colorize) 34 | - [greyscale](/v2/api/greyscale) 35 | - [invert](/v2/api/invert) 36 | - [pixelate](/v2/api/pixelate) 37 | -------------------------------------------------------------------------------- /image/v2/api/cache.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "cache()" 3 | title: "Image::cache" 4 | subtitle: "Cached image processing" 5 | --- 6 | 7 | > public Intervention\Image\ImageManager cache(Closure $callback, [int $lifetime, [bool $returnObj]]) 8 | 9 | Method to create a new cached image instance from a **Closure callback**. Pass a **lifetime** in minutes for the callback and decide whether you want to get an Intervention Image instance as **return value** or just receive the image stream. 10 | 11 | **Note: This method requires the additional package intervention/imagecache.** 12 | 13 | ### Parameters 14 | 15 | #### callback 16 | A closure containing the operations on an image, defining the cached image. 17 | 18 | #### lifetime (optional) 19 | The lifetime in minutes of the image callback in the cache. (Default: `5`) 20 | 21 | #### returnObj (optional) 22 | Decide if you want the method to return an Intervention Image instance or (by default) the image stream. 23 | 24 | ### Return Values 25 | Mixed - based on ```returnObj``` parameter. 26 | 27 | ### Examples 28 | 29 | ```php 30 | // create a cached image and set a lifetime and return as object instead of string 31 | $img = Image::cache(function($image) { 32 | $image->make('public/foo.jpg')->resize(300, 200)->greyscale(); 33 | }, 10, true); 34 | ``` 35 | 36 | ### See also 37 | - [Further Information about Image Caching](/v2/usage/cache) 38 | -------------------------------------------------------------------------------- /image/v2/api/canvas.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "canvas()" 3 | title: "Image::canvas" 4 | subtitle: "Create a new empty image resource" 5 | --- 6 | 7 | > public Intervention\Image\ImageManager canvas(integer $width, integer $height, [mixed $bgcolor]) 8 | 9 | Factory method to create a new empty image instance with given **width and height**. You can define a **background-color** optionally. By default the canvas background is transparent. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | Width of the new image resource. 15 | 16 | #### height 17 | Height of the new image resource. 18 | 19 | #### bgcolor (optional) 20 | Optional Background-color of the image resource. Pass a color in one of the supported [color formats](/v2/getting-started/formats) or just leave it blank to get a transparent background. 21 | 22 | 23 | ### Return Values 24 | Instance of `Intervention\Image\Image` 25 | 26 | ### Examples 27 | 28 | ```php 29 | // create a new empty image resource with transparent background 30 | $img = Image::canvas(800, 600); 31 | 32 | // create a new empty image resource with red background 33 | $img = Image::canvas(32, 32, '#ff0000'); 34 | ``` 35 | 36 | 37 | ### See also 38 | 39 | - [make](/v2/api/make) 40 | - [cache](/v2/api/cache) 41 | -------------------------------------------------------------------------------- /image/v2/api/circle.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "circle()" 3 | title: "Image::circle" 4 | subtitle: "Draw a circle to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image circle(integer $diameter, integer $x, integer $y, [Closure $callback]) 8 | 9 | Draw a circle at given **x, y, coordinates** with given **diameter**. You can define the **appearance** of the circle by an optional closure callback. 10 | 11 | ### Parameters 12 | 13 | #### diameter 14 | Diameter of the circle in pixels. 15 | 16 | #### pos_x 17 | x-coordinate of the center. 18 | 19 | #### pos_y 20 | y-coordinate of the center. 21 | 22 | #### callback (optional) 23 | Define appearance of circle. See examples below. Use the following methods to pass details. 24 | 25 | 26 | > public Intervention\Image\AbstractShape background(string $color) 27 | 28 | Define the background-color of the circle in one of the available [color formats](/v2/getting-started/formats). 29 | 30 | 31 | > public Intervention\Image\AbstractShape border(integer $width, string $color) 32 | 33 | Define the border of the circle. Set width as pixels in the first and the border-color in one of the available [color formats](/v2/getting-started/formats) as second parameter. 34 | 35 | ### Return Values 36 | Instance of `Intervention\Image\Image` 37 | 38 | ### Examples 39 | 40 | ```php 41 | // create empty canvas with background color 42 | $img = Image::canvas(300, 200, '#ddd'); 43 | 44 | // draw a filled blue circle 45 | $img->circle(100, 50, 50, function ($draw) { 46 | $draw->background('#0000ff'); 47 | }); 48 | 49 | // draw a filled blue circle with red border 50 | $img->circle(10, 100, 100, function ($draw) { 51 | $draw->background('#0000ff'); 52 | $draw->border(1, '#f00'); 53 | }); 54 | 55 | // draw an empty circle with 5px border 56 | $img->circle(70, 150, 100, function ($draw) { 57 | $draw->border(5, '000000'); 58 | }); 59 | ``` 60 | 61 | 62 | ### See also 63 | 64 | - [pixel](/v2/api/pixel) 65 | - [line](/v2/api/line) 66 | - [rectangle](/v2/api/rectangle) 67 | - [ellipse](/v2/api/ellipse) 68 | - [polygon](/v2/api/polygon) 69 | -------------------------------------------------------------------------------- /image/v2/api/colorize.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "colorize()" 3 | title: "Image::colorize" 4 | subtitle: "Change the color balance of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image colorize(integer $red, integer $green, integer $blue) 8 | 9 | Change the RGB color values of the current image on the given channels **red**, **green** and **blue**. The input values are normalized so you have to include parameters from ```100``` for maximum color value ```0``` for no change and ```-100``` to take out all the certain color on the image. 10 | 11 | ### Parameters 12 | 13 | #### red 14 | Add or take out a amount of red color on the image. Use values between `-100` and `+100`. 15 | 16 | #### green 17 | Add or take out a amount of green color on the image. Use values between `-100` and `+100`. 18 | 19 | #### blue 20 | Add or take out a amount of blue color on the image. Use values between `-100` and `+100`. 21 | 22 | 23 | ### Return Values 24 | Instance of `Intervention\Image\Image` 25 | 26 | ### Examples 27 | 28 | ```php 29 | // create new Intervention Image 30 | $img = Image::make('public/foo.jpg'); 31 | 32 | // take out red color and add blue 33 | $img->colorize(-100, 0, 100); 34 | 35 | // just add a little green tone to the image 36 | $img->colorize(0, 30, 0); 37 | ``` 38 | 39 | ### See also 40 | 41 | - [brightness](/v2/api/brightness) 42 | - [contrast](/v2/api/contrast) 43 | - [gamma](/v2/api/gamma) 44 | - [greyscale](/v2/api/greyscale) 45 | - [invert](/v2/api/invert) 46 | - [pixelate](/v2/api/pixelate) 47 | -------------------------------------------------------------------------------- /image/v2/api/contrast.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "contrast()" 3 | title: "Image::contrast" 4 | subtitle: "Change the color contrast of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image contrast(integer $level) 8 | 9 | Changes the contrast of the current image by the given **level**. Use values between ```-100``` for min. contrast ```0``` for no change and ```+100``` for max. contrast. 10 | 11 | ### Parameters 12 | 13 | #### level 14 | Level of contrast change applied to the current image. Use values between `-100` and `+100`. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // increase brightness of image 26 | $img->contrast(65); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [brightness](/v2/api/brightness) 32 | - [gamma](/v2/api/gamma) 33 | - [colorize](/v2/api/colorize) 34 | - [greyscale](/v2/api/greyscale) 35 | - [invert](/v2/api/invert) 36 | - [pixelate](/v2/api/pixelate) 37 | -------------------------------------------------------------------------------- /image/v2/api/crop.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "crop()" 3 | title: "Image::crop" 4 | subtitle: "Cut out a rectangular part of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image crop(int $width, int $height, [int $x, int $y]) 8 | 9 | Cut out a rectangular part of the current image with given **width and height**. Define optional **x,y coordinates** to move the top-left corner of the cutout to a certain position. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | Width of the rectangular cutout. 15 | 16 | #### height 17 | Height of the rectangular cutout. 18 | 19 | #### x (optional) 20 | X-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image. 21 | 22 | #### y (optional) 23 | Y-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image. 24 | 25 | ### Return Values 26 | Instance of `Intervention\Image\Image` 27 | 28 | ### Examples 29 | 30 | ```php 31 | // open file a image resource 32 | $img = Image::make('public/foo.jpg'); 33 | 34 | // crop image 35 | $img->crop(100, 100, 25, 25); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [resize](/v2/api/resize) 41 | - [resizeCanvas](/v2/api/resize-canvas) 42 | - [fit](/v2/api/fit) 43 | - [trim](/v2/api/trim) 44 | -------------------------------------------------------------------------------- /image/v2/api/destroy.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "destroy()" 3 | title: "Image::destroy" 4 | subtitle: "Free up memory" 5 | --- 6 | 7 | > public Intervention\Image\Image destroy() 8 | 9 | Frees memory associated with the current image instance **before** the PHP script ends. Normally resources are destroyed automatically **after** the script is finished. 10 | 11 | Of course, the image instance is no longer usable after the method has been called. 12 | 13 | ### Parameters 14 | none 15 | 16 | ### Return Values 17 | none 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create an image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // perform some modifications 26 | $img->resize(320, 240); 27 | $img->save('public/small.jpg'); 28 | 29 | // destroy resource 30 | $img->destroy(); 31 | ``` 32 | -------------------------------------------------------------------------------- /image/v2/api/ellipse.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "ellipse()" 3 | title: "Image::ellipse" 4 | subtitle: "Draw an ellipse to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image ellipse(int $width, int $height, int $x, int $y, [Closure $callback]) 8 | 9 | Draw a **colored** ellipse at given **x, y, coordinates**. You can define **width** and **height** and set the **appearance** of the circle by an optional closure callback. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | width of the ellipse. Default: `10` 15 | 16 | #### height 17 | The ellipse height. Default: `10` 18 | 19 | #### x 20 | x-coordinate of the center. 21 | 22 | #### y 23 | y-coordinate of the center. 24 | 25 | #### callback (optional) 26 | Define appearance of ellipse. See examples below. Use the following methods to pass details. 27 | 28 | > public Intervention\Image\AbstractShape background(string $color) 29 | 30 | Define the background-color of the ellipse in one of the available [color formats](/v2/getting-started/formats). 31 | 32 | > public Intervention\Image\AbstractShape border(integer $width, string $color) 33 | 34 | Define the border of the ellipse. Set width as pixels in the first and the border-color in one of the available [color formats](/v2/getting-started/formats) as second parameter. 35 | 36 | ### Return Values 37 | Instance of `Intervention\Image\Image` 38 | 39 | ### Examples 40 | 41 | ```php 42 | // create empty canvas with background color 43 | $img = Image::canvas(800, 600, '#ddd'); 44 | 45 | // draw a filled blue ellipse 46 | $img->ellipse(25, 30, 50, 50, function ($draw) { 47 | $draw->background('#0000ff'); 48 | }); 49 | 50 | // draw a filled blue ellipse with red border 51 | $img->ellipse(60, 120, 100, 100, function ($draw) { 52 | $draw->background('#0000ff'); 53 | $draw->border(1, '#ff0000'); 54 | }); 55 | 56 | // draw an empty ellipse with a 5px border 57 | $img->ellipse(150, 200, 300, 200, function ($draw) { 58 | $draw->border(5, 'fff'); 59 | }); 60 | ``` 61 | 62 | 63 | ### See also 64 | 65 | - [pixel](/v2/api/pixel) 66 | - [line](/v2/api/line) 67 | - [rectangle](/v2/api/rectangle) 68 | - [circle](/v2/api/circle) 69 | - [polygon](/v2/api/polygon) 70 | -------------------------------------------------------------------------------- /image/v2/api/encode.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "encode()" 3 | title: "Image::encode" 4 | subtitle: "Encode image" 5 | --- 6 | 7 | > public Intervention\Image\Image encode([mixed $format, [int $quality]]) 8 | 9 | Encodes the current image in given **format** and given **image quality**. 10 | 11 | ### Parameters 12 | 13 | #### format (optional) 14 | Define the encoding format from one of the following formats: 15 | 16 | - **jpg** — return JPEG encoded image data 17 | - **png** — return Portable Network Graphics (PNG) encoded image data 18 | - **gif** — return Graphics Interchange Format (GIF) encoded image data 19 | - **tif** — return Tagged Image File Format (TIFF) encoded image data 20 | - **bmp** — return Bitmap (BMP) encoded image data 21 | - **ico** — return ICO encoded image data 22 | - **psd** — return Photoshop Document (PSD) encoded image data 23 | - **webp** — return WebP encoded image data 24 | - **data-url** — encode current image data in data URI scheme (RFC 2397) 25 | 26 | By default the method will return data encoded in the type of the current image. If no image type is defined yet, data will be encoded as jpeg. 27 | 28 | #### quality (optional) 29 | Define the quality of the encoded image optionally. Data ranging from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: `90`. 30 | 31 | ### Return Values 32 | Instance of `Intervention\Image\Image` with attached encoded image data. Instance can be casted to string to access data. 33 | 34 | ### Examples 35 | 36 | ```php 37 | // encode png image as jpg 38 | $jpg = (string) Image::make('public/foo.png')->encode('jpg', 75); 39 | 40 | // encode image as data-url 41 | $data = (string) Image::make('public/bar.png')->encode('data-url'); 42 | ``` 43 | 44 | ### See also 45 | 46 | - [save](/v2/api/save) 47 | -------------------------------------------------------------------------------- /image/v2/api/exif.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "exif()" 3 | title: "Image::exif" 4 | subtitle: "Read Exif meta data from the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image exif([string $key]) 8 | 9 | Read Exif meta data from current image. **Image object must be instantiated from file path to read the EXIF data correctly.** 10 | 11 | The Imagick driver comes with built-in exif support since version 2.3.9 of this library. Otherwise PHP must be compiled in with ```--enable-exif``` to use this method. Windows users must also have the ```mbstring``` extension enabled. When both the Imagick driver and the extension are available, the extension will be used. 12 | 13 | ### Parameters 14 | 15 | #### key (optional) 16 | Optionally index key to retrieve only particular data. By default all data available will be loaded. 17 | 18 | ### Return Values 19 | Associative array of all Exif data available or mixed data for particular value. If no meta data can be found, method will return `null`. 20 | 21 | ### Examples 22 | 23 | ```php 24 | // read all existing data into an array 25 | $data = Image::make('public/foo.jpg')->exif(); 26 | 27 | // read model of the camera 28 | $name = Image::make('public/foo.jpg')->exif('Model'); 29 | ``` 30 | 31 | ### See also 32 | 33 | - [iptc](/v2/api/iptc) 34 | - [orientate](/v2/api/orientate) 35 | -------------------------------------------------------------------------------- /image/v2/api/filesize.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "filesize()" 3 | title: "Image::filesize" 4 | subtitle: "Gets file size of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image filesize() 8 | 9 | Gets the file size for the current image, if instance is initiated from an actual file. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | 17 | Returns the size of the image file in bytes or `false` if image instance is not created from a file. 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create an image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // get file size 26 | $size = $img->filesize(); 27 | ``` 28 | -------------------------------------------------------------------------------- /image/v2/api/fill.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "fill()" 3 | title: "Image::fill" 4 | subtitle: "Fill the current image with a color or pattern" 5 | --- 6 | 7 | > public Intervention\Image\Image fill(mixed $filling, [integer $x, integer $y]) 8 | 9 | Fill current image with given **color** or another **image** used as tile for filling. Pass optional **x, y coordinates** to start at a certain point. 10 | 11 | If a certain position is defined, the color at that point on the original image is used to perform a flood fill. If no x,y coordinates are passed, the whole picture is filled no matter what is beneath. 12 | 13 | ### Parameters 14 | 15 | #### filling 16 | The fill color or image pattern. Pass a **color** as one of the different [color formats](/v2/getting-started/formats) or to fill the image with tiles an image resource in the following formats: 17 | 18 | - **string** - Path of the image in filesystem. 19 | - **string** - URL of an image (```allow_url_fopen``` must be enabled). 20 | - **string** - Binary image data. 21 | - **string** - Data-URL encoded image data. 22 | - **string** - Base64 encoded image data. 23 | - **resource** - PHP resource of type gd. (when using GD driver) 24 | - **object** - Imagick instance (when using Imagick driver) 25 | - **object** - `Intervention\Image\Image` instance 26 | - **object** - SplFileInfo instance (To handle Laravel file uploads via `Symfony\Component\HttpFoundation\File\UploadedFile`) 27 | 28 | #### x (optional) 29 | Starting point on x-axis for the filling. 30 | 31 | #### y (optional) 32 | Starting point on y-axis for the filling. 33 | 34 | **If a x, y coordinate is defined the filling will be flood filled based on the color at this position.** 35 | 36 | 37 | ### Return Values 38 | Instance of `Intervention\Image\Image` 39 | 40 | ### Examples 41 | 42 | ```php 43 | // create empty canvas 44 | $img = Image::canvas(800, 600); 45 | 46 | // fill image with color 47 | $img->fill('#cccccc'); 48 | 49 | // fill image with tiled image 50 | $img->fill('tile.png'); 51 | 52 | // flood fill image with color 53 | $img->fill('#ff00ff', 0, 0); 54 | ``` 55 | 56 | ### See also 57 | 58 | - [pixel](/v2/api/pixel) 59 | -------------------------------------------------------------------------------- /image/v2/api/filter.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "filter()" 3 | title: "Image::filter" 4 | subtitle: "Apply a predefined filter to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image filter(Intervention\Image\Filters\FilterInterface $filter) 8 | 9 | The method applies custom filter on current image. Filters are bundles of commands which apply combined operations and effects on an image. Any filters must implement the ```Intervention\Image\Filters\FilterInterface``` and call any method that can be applied to an Intervention Image instance. 10 | 11 | ### Parameters 12 | 13 | #### filter 14 | Instance of your custom filter. See example of `DemoFilter` below which combines a greyscale/pixelate effect. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // init new image instance 23 | $img = Image::make('foo.jpg'); 24 | 25 | // apply filter 26 | $img->filter(new DemoFilter(45)); 27 | ``` 28 | 29 | #### DemoFilter Example 30 | 31 | ```php 32 | size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE; 58 | } 59 | 60 | /** 61 | * Applies filter effects to given image 62 | * 63 | * @param Intervention\Image\Image $image 64 | * @return Intervention\Image\Image 65 | */ 66 | public function applyFilter(\Intervention\Image\Image $image) 67 | { 68 | $image->pixelate($this->size); 69 | $image->greyscale(); 70 | 71 | return $image; 72 | } 73 | } 74 | ``` 75 | -------------------------------------------------------------------------------- /image/v2/api/fit.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "fit()" 3 | title: "Image::fit" 4 | subtitle: "Cut out and resize a rectangular part of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image fit(int $width, [[int $height], [Closure $callback, [string $position]]]) 8 | 9 | Combine cropping and resizing to format image in a smart way. The method will find the best fitting aspect ratio of your given **width and height** on the current image automatically, cut it out and resize it to the given dimension. You may pass an optional Closure **callback** as third parameter, to prevent possible upsizing and a custom **position** of the cutout as fourth parameter. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | The width the image will be resized to after cropping out the best fitting aspect ratio. 15 | 16 | #### height (optional) 17 | The height the image will be resized to after cropping out the best fitting aspect ratio. If no height is given, method will use same value as width. 18 | 19 | #### callback (optional) 20 | Closure callback defining constraint to prevent unwanted **upsizing** of the image. See examples below. 21 | 22 | > public Intervention\Image\Size upsize() 23 | 24 | Keep image from being upsized. 25 | 26 | #### position (optional) 27 | Set a position where cutout will be positioned. By default the best fitting aspect ration is centered. 28 | 29 | The possible values are: 30 | 31 | - top-left 32 | - top 33 | - top-right 34 | - left 35 | - center (default) 36 | - right 37 | - bottom-left 38 | - bottom 39 | - bottom-right 40 | 41 | 42 | ### Return Values 43 | Instance of `Intervention\Image\Image` 44 | 45 | ### Examples 46 | 47 | ```php 48 | // open file a image resource 49 | $img = Image::make('public/foo.jpg'); 50 | 51 | // crop the best fitting 5:3 (600x360) ratio and resize to 600x360 pixel 52 | $img->fit(600, 360); 53 | 54 | // crop the best fitting 1:1 ratio (200x200) and resize to 200x200 pixel 55 | $img->fit(200); 56 | 57 | // add callback functionality to retain maximal original image size 58 | $img->fit(800, 600, function ($constraint) { 59 | $constraint->upsize(); 60 | }); 61 | ``` 62 | 63 | ### See also 64 | 65 | - [resize](/v2/api/resize) 66 | - [resizeCanvas](/v2/api/resize-canvas) 67 | - [crop](/v2/api/crop) 68 | - [trim](/v2/api/trim) 69 | -------------------------------------------------------------------------------- /image/v2/api/flip.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "flip()" 3 | title: "Image::flip" 4 | subtitle: "Mirror the current image vertically or horizontally" 5 | --- 6 | 7 | > public Intervention\Image\Image flip([string $mode]) 8 | 9 | Mirror the current image horizontally or vertically by specifying the **mode**. 10 | 11 | ### Parameters 12 | 13 | #### mode (optional) 14 | Specify the mode the image will be flipped. You can set ```h``` for horizontal (default) or ```v``` for vertical flip. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create Image from file 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // flip image vertically 26 | $img->flip('v'); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [rotate](/v2/api/rotate) 32 | -------------------------------------------------------------------------------- /image/v2/api/gamma.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "gamma()" 3 | title: "Image::gamma" 4 | subtitle: "Apply gamma correction to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image gamma(float $correction) 8 | 9 | Apply a gamma correction operation on the current image. 10 | 11 | ### Parameters 12 | 13 | #### correction 14 | Gamma compensation value. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // apply gamma correction 26 | $img->gamma(1.6); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [brightness](/v2/api/brightness) 32 | - [contrast](/v2/api/contrast) 33 | - [colorize](/v2/api/colorize) 34 | - [greyscale](/v2/api/greyscale) 35 | - [invert](/v2/api/invert) 36 | - [pixelate](/v2/api/pixelate) 37 | -------------------------------------------------------------------------------- /image/v2/api/get-core.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "getCore()" 3 | title: "Image::getCore" 4 | subtitle: "Read core instance of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image getCore() 8 | 9 | Returns the current image in core format of the particular driver. If you're using GD, you will get the the current **GD resource** as return value. If you have setup the Imagick driver, the method will return the current image information as an **Imagick object**. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | 17 | mixed - depends on configured driver 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // get Imagick instance 26 | $imagick = $img->getCore(); 27 | 28 | // apply Imagick function 29 | $imagick->embossImage(0, 1); 30 | ``` 31 | -------------------------------------------------------------------------------- /image/v2/api/greyscale.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "greyscale()" 3 | title: "Image::greyscale" 4 | subtitle: "Turn the current image into a greyscale version" 5 | --- 6 | 7 | > public Intervention\Image\Image greyscale() 8 | 9 | Turns image into a greyscale version. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | Instance of `Intervention\Image\Image` 17 | 18 | ### Examples 19 | 20 | ```php 21 | // create new Intervention Image and turn it into greyscale version 22 | $img = Image::make('public/foo.jpg')->greyscale(); 23 | ``` 24 | 25 | ### See also 26 | 27 | - [brightness](/v2/api/brightness) 28 | - [contrast](/v2/api/contrast) 29 | - [colorize](/v2/api/colorize) 30 | - [invert](/v2/api/invert) 31 | - [pixelate](/v2/api/pixelate) 32 | -------------------------------------------------------------------------------- /image/v2/api/height.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "height()" 3 | title: "Image::height" 4 | subtitle: "Get the height in pixels of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image height() 8 | 9 | Returns the height in pixels of the current image. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | Height of current image as integer 17 | 18 | ### Examples 19 | 20 | ```php 21 | // read height of image 22 | $height = Image::make('public/foo.jpg')->height(); 23 | ``` 24 | 25 | ## See also 26 | 27 | - [width](/v2/api/width) 28 | -------------------------------------------------------------------------------- /image/v2/api/heighten.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "heighten()" 3 | title: "Image::heighten" 4 | subtitle: "Resize image proportionally to given height" 5 | --- 6 | 7 | > public Intervention\Image\Image heighten(integer $height, [Closure $callback]) 8 | 9 | Resizes the current image to new **height**, constraining aspect ratio. Pass an optional Closure **callback** as third parameter, to apply additional constraints like preventing possible upsizing. 10 | 11 | ### Parameters 12 | 13 | #### height 14 | The new height of the image 15 | 16 | #### callback (optional) 17 | Closure callback defining constraint to prevent unwanted **upsizing** of the image. See examples below. 18 | 19 | > public Intervention\Image\Size upsize() 20 | 21 | Keep image from being upsized. 22 | 23 | ### Return Values 24 | Resized instance of `Intervention\Image\Image` 25 | 26 | ### Examples 27 | 28 | ```php 29 | // resize image to new height 30 | $img = Image::make('public/foo.jpg')->heighten(100); 31 | 32 | // resize image to new height but do not exceed original size 33 | $img = Image::make('public/foo.jpg')->heighten(100, function ($constraint) { 34 | $constraint->upsize(); 35 | }); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [widen](/v2/api/widen) 41 | - [resize](/v2/api/resize) 42 | -------------------------------------------------------------------------------- /image/v2/api/insert.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "insert()" 3 | title: "Image::insert" 4 | subtitle: "Place another image on current image" 5 | --- 6 | 7 | > public Intervention\Image\Image insert(mixed $source, [string $position, [integer $x, integer $y]]) 8 | 9 | Paste a given **image source** over the current image with an optional **position** and a **offset coordinate**. This method can be used to apply another image as watermark because the transparency values are maintained. 10 | 11 | ### Parameters 12 | 13 | #### source 14 | The image source that will inserted on top of the current image. The method can handle the following types of input: 15 | 16 | - **string** - Path of the image in filesystem. 17 | - **string** - URL of an image (```allow_url_fopen``` must be enabled). 18 | - **string** - Binary image data. 19 | - **string** - Data-URL encoded image data. 20 | - **string** - Base64 encoded image data. 21 | - **resource** - PHP resource of type gd. (when using GD driver) 22 | - **object** - Imagick instance (when using Imagick driver) 23 | - **object** - `Intervention\Image\Image` instance 24 | - **object** - SplFileInfo instance (To handle Laravel file uploads via `Symfony\Component\HttpFoundation\File\UploadedFile`) 25 | 26 | #### position (optional) 27 | Set a position where image will be inserted. For example if you are setting the anchor to ```bottom-left``` the image will be positioned at the bottom-left border of the current image. The position of the new image will be calculated relatively to this location. 28 | 29 | The possible values are: 30 | 31 | - top-left (default) 32 | - top 33 | - top-right 34 | - left 35 | - center 36 | - right 37 | - bottom-left 38 | - bottom 39 | - bottom-right 40 | 41 | #### x (optional) 42 | Optional relative offset of the new image on x-axis of the current image. Offset will be calculated relative to the position parameter. Default: 0 43 | 44 | #### y (optional) 45 | Optional relative offset of the new image on y-axis of the current image. Offset will be calculated relative to the position parameter. Default: 0 46 | 47 | ### Return Values 48 | Instance of `Intervention\Image\Image` 49 | 50 | ### Examples 51 | 52 | ```php 53 | // create new Intervention Image 54 | $img = Image::make('public/foo.jpg'); 55 | 56 | // paste another image 57 | $img->insert('public/bar.png'); 58 | 59 | // create a new Image instance for inserting 60 | $watermark = Image::make('public/watermark.png'); 61 | $img->insert($watermark, 'center'); 62 | 63 | // insert watermark at bottom-right corner with 10px offset 64 | $img->insert('public/watermark.png', 'bottom-right', 10, 10); 65 | ``` 66 | 67 | ### See also 68 | 69 | - [mask](/v2/api/mask) 70 | 71 | -------------------------------------------------------------------------------- /image/v2/api/interlace.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "interlace()" 3 | title: "Image::interlace" 4 | subtitle: "Enable or disabled interlaced mode of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image interlace([boolean $interlace]) 8 | 9 | Determine whether an image should be encoded in interlaced or standard mode by toggling **interlace** mode with a boolean parameter. If an JPEG image is set interlaced the image will be processed as a progressive JPEG. 10 | 11 | ### Parameters 12 | 13 | #### interlace (optional) 14 | If interlace is set to boolean `true` the image will be encoded interlaced. If the parameter is set to `false` interlaced mode is turned off. Default: `true` 15 | 16 | 17 | ### Return Values 18 | Instance of `Intervention\Image\Image` 19 | 20 | ### Examples 21 | 22 | ```php 23 | // open image 24 | $img = Image::make('public/foo.png'); 25 | 26 | // enable interlacing 27 | $img->interlace(); 28 | 29 | // save image interlaced 30 | $img->save(); 31 | 32 | // open interlaced image 33 | $img = Image::make('public/interlaced.gif'); 34 | 35 | // disable interlacing 36 | $img->interlace(false); 37 | 38 | // save image in standard mode 39 | $img->save(); 40 | ``` 41 | 42 | ### See also 43 | 44 | - [limitColors](/v2/api/limit-colors) 45 | - [save](/v2/api/save) 46 | - [encode](/v2/api/encode) 47 | -------------------------------------------------------------------------------- /image/v2/api/invert.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "invert()" 3 | title: "Image::invert" 4 | subtitle: "Invert the colors of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image invert() 8 | 9 | Invert all colors of the current image. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | Instance of `Intervention\Image\Image` 17 | 18 | ### Examples 19 | 20 | ```php 21 | // create Image from file and reverse colors 22 | $img = Image::make('public/foo.jpg')->invert(); 23 | ``` 24 | 25 | ### See also 26 | 27 | - [brightness](/v2/api/brightness) 28 | - [contrast](/v2/api/contrast) 29 | -------------------------------------------------------------------------------- /image/v2/api/iptc.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "iptc()" 3 | title: "Image::iptc" 4 | subtitle: "Reads IPTC meta data from the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image iptc([string $key]) 8 | 9 | Read IPTC meta data from current image. 10 | 11 | ### Parameters 12 | 13 | #### key (optional) 14 | Optionally index key to retrieve only particular value. By default all data available will be parsed. 15 | 16 | 17 | ### Return Values 18 | Associative array of all meta data values available or mixed data for particular value. If no meta data can be found, method will return `null`. 19 | 20 | ### Examples 21 | 22 | ```php 23 | // read all existing data into an array 24 | $data = Image::make('public/foo.jpg')->iptc(); 25 | 26 | // read only 'Copyright' 27 | $copyright = Image::make('public/foo.jpg')->iptc('Copyright'); 28 | ``` 29 | 30 | ### See also 31 | 32 | - [exif](/v2/api/exif) 33 | - [orientate](/v2/api/orientate) 34 | -------------------------------------------------------------------------------- /image/v2/api/limit-colors.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "limitColors()" 3 | title: "Image::limitColors" 4 | subtitle: "Reduce number of colors for the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image limitColors(integer $count, [mixed $matte]) 8 | 9 | Method converts the existing colors of the current image into a color table with a given maximum **count** of colors. The function preserves as much alpha channel information as possible and blends transarent pixels against a optional **matte color**. 10 | 11 | ### Parameters 12 | 13 | #### count 14 | Maximum number of colors that should be retained in the color palette. Or `null` to convert to truecolor. 15 | 16 | #### matte (optional) 17 | A color to blend transparent pixels against. Can be defined in one of the different [color formats](/v2/getting-started/formats). Default: no matte color 18 | 19 | ### Return Values 20 | Instance of `Intervention\Image\Image` 21 | 22 | ### Examples 23 | 24 | ```php 25 | // open PNG-32 image from file 26 | $img = Image::make('public/foo.png'); 27 | 28 | // limit colors to 255 (PNG-8) blending transparency against orange 29 | $img->limitColors(255, '#ff9900'); 30 | ``` 31 | 32 | ### See also 33 | 34 | - [save](/v2/api/save) 35 | - [encode](/v2/api/encode) 36 | -------------------------------------------------------------------------------- /image/v2/api/line.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "line()" 3 | title: "Image::line" 4 | subtitle: "Draw a line to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image line(int $x1, int $y1, int $x2, int $y2, [Closure $callback]) 8 | 9 | Draw a line from **x,y point 1** to **x,y point 2** on current image. Define **color and/or width** of line in an optional Closure callback. 10 | 11 | ### Parameters 12 | 13 | #### x1 14 | X-Coordinate of the starting point. 15 | 16 | #### y1 17 | Y-Coordinate of the starting point. 18 | 19 | #### x2 20 | X-Coordinate of the end point. 21 | 22 | #### y2 23 | Y-Coordinate of the end point. 24 | 25 | #### callback 26 | Define appearance of line. See examples below. Use the following methods to pass details. 27 | 28 | > public Intervention\Image\AbstractShape color(string $color) 29 | 30 | Set color of the line in one of the available [color formats](/v2/getting-started/formats). Default: `#000000` 31 | 32 | > public Intervention\Image\AbstractShape width(integer $width) 33 | 34 | Set the width of the line in pixels. **Option is not available with GD driver** Default: `1` 35 | 36 | 37 | ### Return Values 38 | Instance of `Intervention\Image\Image` 39 | 40 | ### Examples 41 | 42 | ```php 43 | // create empty canvas with background color 44 | $img = Image::canvas(100, 100, '#ddd'); 45 | 46 | // draw a blue line 47 | $img->line(10, 10, 100, 10, function ($draw) { 48 | $draw->color('#0000ff'); 49 | }); 50 | 51 | // draw a red line with 5 pixel width 52 | $img->line(10, 10, 195, 195, function ($draw) { 53 | $draw->color('#f00'); 54 | $draw->width(5); 55 | }); 56 | ``` 57 | 58 | ### See also 59 | 60 | - [pixel](/v2/api/pixel) 61 | - [rectangle](/v2/api/rectangle) 62 | - [circle](/v2/api/circle) 63 | - [ellipse](/v2/api/ellipse) 64 | - [polygon](/v2/api/polygon) 65 | -------------------------------------------------------------------------------- /image/v2/api/make.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "make()" 3 | title: "Image::make" 4 | subtitle: "Create a new image resource" 5 | --- 6 | 7 | > public static Intervention\Image\ImageManager make(mixed $source) 8 | 9 | Universal factory method to create a new image instance from **source**. The method is highly variable to read all the input types listed below. 10 | 11 | ### Parameters 12 | 13 | #### source 14 | 15 | Source to create an image from. The method responds to the following input types: 16 | 17 | - **string** - Path of the image in filesystem. 18 | - **string** - URL of an image (```allow_url_fopen``` must be enabled). 19 | - **string** - Binary image data. 20 | - **string** - Data-URL encoded image data. 21 | - **string** - Base64 encoded image data. 22 | - **resource** - PHP resource of type gd. (when using GD driver) 23 | - **object** - Imagick instance (when using Imagick driver) 24 | - **object** - `Intervention\Image\Image` instance 25 | - **object** - SplFileInfo instance (To handle Laravel file uploads via `Symfony\Component\HttpFoundation\File\UploadedFile`) 26 | 27 | ### Return Values 28 | Instance of `Intervention\Image\Image` 29 | 30 | ### Examples 31 | 32 | ```php 33 | // create a new image resource from file 34 | $img = Image::make('public/foo.jpg'); 35 | 36 | // or create a new image resource from binary data 37 | $img = Image::make(file_get_contents('public/foo.jpg')); 38 | 39 | // create a new image from gd resource 40 | $img = Image::make(imagecreatefromjpeg('public/foo.jpg')); 41 | 42 | // create a new image directly from an url 43 | $img = Image::make('http://example.com/example.jpg'); 44 | 45 | // create a new image directly from Laravel file upload 46 | $img = Image::make(Request::file('photo')); 47 | ``` 48 | 49 | ### See also 50 | 51 | - [canvas](/v2/api/canvas) 52 | - [cache](/v2/api/cache) 53 | 54 | -------------------------------------------------------------------------------- /image/v2/api/mask.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "mask()" 3 | title: "Image::mask" 4 | subtitle: "Apply alpha masking to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image mask(mixed $source, [bool $mask_with_alpha]) 8 | 9 | Apply a given **image source** as alpha mask to the current image to change current opacity. Mask will be resized to the current image size. By default a greyscale version of the mask is converted to alpha values, but you can set **mask_with_alpha** to apply the actual alpha channel. Any transparency values of the current image will be maintained. 10 | 11 | ### Parameters 12 | 13 | #### source 14 | The image source that will be applied as alpha mask. The method can handle the following types of input: 15 | 16 | - **string** - Path of the image in filesystem. 17 | - **string** - URL of an image (```allow_url_fopen``` must be enabled). 18 | - **string** - Binary image data. 19 | - **string** - Data-URL encoded image data. 20 | - **string** - Base64 encoded image data. 21 | - **resource** - PHP resource of type gd. (when using GD driver) 22 | - **object** - Imagick instance (when using Imagick driver) 23 | - **object** - `Intervention\Image\Image` instance 24 | - **object** - SplFileInfo instance (To handle Laravel file uploads via `Symfony\Component\HttpFoundation\File\UploadedFile`) 25 | 26 | 27 | #### mask_with_alpha (optional) 28 | Set this to `true` to apply the actual alpha channel as mask to the current image instead of the color values. Default: `false` 29 | 30 | ### Return Values 31 | Instance of `Intervention\Image\Image` 32 | 33 | ### Examples 34 | 35 | ```php 36 | // create new Intervention Image 37 | $img = Image::make('public/foo.jpg'); 38 | 39 | // Apply another image as alpha mask on image 40 | $img->mask('public/mask.png'); 41 | 42 | // Apply a second image with alpha channel masking 43 | $img->mask('public/alpha.png', true); 44 | ``` 45 | 46 | ### See also 47 | 48 | - [fill](/v2/api/fill) 49 | - [opacity](/v2/api/opacity) 50 | - [insert](/v2/api/insert) 51 | -------------------------------------------------------------------------------- /image/v2/api/mime.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "mime()" 3 | title: "Image::mime" 4 | subtitle: "Get MIME Type of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image mime() 8 | 9 | Read MIME Type of current image instance, if it's already defined. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | MIME Type of current image. 17 | 18 | ### Examples 19 | 20 | ```php 21 | // read mime type of image 22 | $mime = Image::make('public/foo.jpg')->mime(); 23 | ``` 24 | 25 | ### See also 26 | 27 | - [width](/v2/api/width) 28 | - [height](/v2/api/height) 29 | - [exif](/v2/api/exif) 30 | -------------------------------------------------------------------------------- /image/v2/api/opacity.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "opacity()" 3 | title: "Image::opacity" 4 | subtitle: "Set opacity of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image opacity(integer $transparency) 8 | 9 | Set the **opacity** in percent of the current image ranging from 100% for opaque and 0% for full transparency. 10 | 11 | **Note: Performance intensive on larger images. Use with care.** 12 | 13 | ### Parameters 14 | 15 | #### transparency 16 | The new percent of transparency as integer for the current image. 17 | 18 | ### Return Values 19 | Instance of `Intervention\Image\Image` 20 | 21 | ### Examples 22 | 23 | ```php 24 | // create Image from file and set transparency to 50% 25 | Image::make('public/foo.jpg')->opacity(50); 26 | 27 | // create new Intervention Image from file and set image full transparent 28 | $img = Image::make('public/foo.jpg'); 29 | $img->opacity(0); 30 | ``` 31 | 32 | ### See also 33 | 34 | - [fill](/v2/api/fill) 35 | - [mask](/v2/api/mask) 36 | -------------------------------------------------------------------------------- /image/v2/api/orientate.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "orientate()" 3 | title: "Image::orientate" 4 | subtitle: "Adjusts the current image orientation automatically" 5 | --- 6 | 7 | > public Intervention\Image\Image orientate() 8 | 9 | This method reads the EXIF image profile setting 'Orientation' and performs a rotation on the image to display the image correctly. **Image object must be instantiated from file path to read the EXIF data correctly.** 10 | 11 | **Note: PHP must be compiled in with `--enable-exif` to use this method. Windows users must also have the `mbstring` extension enabled.** 12 | 13 | ### Parameters 14 | 15 | None 16 | 17 | ### Return Values 18 | Instance of `Intervention\Image\Image` 19 | 20 | ### Examples 21 | 22 | ```php 23 | // instantiate image with auto-orientation 24 | $img = Image::make('foo.jpg')->orientate(); 25 | ``` 26 | 27 | ### See also 28 | 29 | - [exif](/v2/api/exif) 30 | -------------------------------------------------------------------------------- /image/v2/api/pick-color.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "pickColor()" 3 | title: "Image::pickColor" 4 | subtitle: "Pick a color out of the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image pickColor(int $x, int $y, [string $format]) 8 | 9 | Pick a color at **point x, y** out of current image and return in optional given **format**. 10 | 11 | ### Parameters 12 | 13 | #### x 14 | x-coordinate of the pixel the color is picked from. 15 | 16 | #### y 17 | y-coordinate of the pixel the color is picked from. 18 | 19 | #### format (optional) 20 | Select the color to be formated in one of the different types: 21 | 22 | - **array**: `[255, 255, 255, 1]` 23 | - **string (rgb)**: `rgb(255, 255, 255)` 24 | - **string (rgba)**: `rgba(255, 255, 255, 0.5)` 25 | - **string (hex)**: `#cccccc` 26 | - **int**: `16776956` 27 | 28 | By default the method returns the RGB value of that pixel as an array. Use the integer format to pass colors directly into any GD Library functions. 29 | 30 | ### Return Values 31 | mixed - Depends on format parameter. By default an array of the RGB and alpha values. 32 | 33 | ### Examples 34 | 35 | ```php 36 | // create an image 37 | $img = Image::make('public/foo.jpg'); 38 | 39 | // pick a color at position as array 40 | $arraycolor = $img->pickColor(100, 100); 41 | 42 | // pick a color at position as integer 43 | $intcolor = $img->pickColor(100, 100, 'int'); 44 | 45 | // pick a color at position and format it as hex string 46 | $hexcolor = $img->pickColor(100, 100, 'hex'); 47 | ``` 48 | -------------------------------------------------------------------------------- /image/v2/api/pixel.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "pixel()" 3 | title: "Image::pixel" 4 | subtitle: "Draw a single pixel to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image pixel(mixed $color, integer $x, integer $y) 8 | 9 | Draw a single pixel in given **color** on **x, y position**. 10 | 11 | ### Parameters 12 | 13 | #### color 14 | The color of the pixel. Pass a color in one of the different [color formats](/v2/getting-started/formats). 15 | 16 | #### x 17 | x-coordinate of the pixel. 18 | 19 | #### y 20 | y-coordinate of the pixel. 21 | 22 | ### Return Values 23 | Instance of `Intervention\Image\Image` 24 | 25 | ### Examples 26 | 27 | ```php 28 | // create empty canvas with background color 29 | $img = Image::canvas(100, 100, '#ddd'); 30 | 31 | // draw a blue pixel 32 | $img->pixel('#0000ff', 32, 32); 33 | 34 | // draw a red pixel 35 | $img->pixel('#ff0000', 64, 64); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [line](/v2/api/line) 41 | - [rectangle](/v2/api/rectangle) 42 | - [circle](/v2/api/circle) 43 | - [ellipse](/v2/api/ellipse) 44 | - [polygon](/v2/api/polygon) 45 | -------------------------------------------------------------------------------- /image/v2/api/pixelate.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "pixelate()" 3 | title: "Image::pixelate" 4 | subtitle: "Apply pixelation filter to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image pixelate(integer $size) 8 | 9 | Applies a pixelation effect to the current image with a given **size** of pixels. 10 | 11 | ### Parameters 12 | 13 | #### size 14 | Size of the pixels. 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // apply pixelation effect 26 | $img->pixelate(12); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [brightness](/v2/api/brightness) 32 | - [contrast](/v2/api/contrast) 33 | - [greyscale](/v2/api/greyscale) 34 | - [invert](/v2/api/invert) 35 | -------------------------------------------------------------------------------- /image/v2/api/polygon.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "polygon()" 3 | title: "Image::polygon" 4 | subtitle: "Draw a polygon to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image polygon(array $points, [Closure $callback]) 8 | 9 | Draw a **colored** polygon with given **points**. You can define the **appearance** of the polygon by an optional closure callback. 10 | 11 | ### Parameters 12 | 13 | #### points 14 | Points of the polygon defined by a single-dimensional array alternating x, y points. **See examples below.** 15 | 16 | #### callback (optional) 17 | Define appearance of polygon. Use the following methods to pass details. 18 | 19 | > public Intervention\Image\AbstractShape background(string $color) 20 | 21 | Define the background-color of the polygon in one of the available [color formats](/v2/getting-started/formats). 22 | 23 | > public Intervention\Image\AbstractShape border(integer $width, string $color) 24 | 25 | Define the border of the polygon. Set width as pixels in the first and the border-color in one of the available [color formats](/v2/getting-started/formats) as second parameter. 26 | 27 | ### Return Values 28 | Instance of `Intervention\Image\Image` 29 | 30 | ### Examples 31 | 32 | ```php 33 | // create empty canvas with background color 34 | $img = Image::canvas(800, 600, '#ddd'); 35 | 36 | // define polygon points 37 | $points = [ 38 | 40, 50, // Point 1 (x, y) 39 | 20, 240, // Point 2 (x, y) 40 | 60, 60, // Point 3 (x, y) 41 | 240, 20, // Point 4 (x, y) 42 | 50, 40, // Point 5 (x, y) 43 | 10, 10 // Point 6 (x, y) 44 | ]; 45 | 46 | // draw a filled blue polygon with red border 47 | $img->polygon($points, function ($draw) { 48 | $draw->background('#0000ff'); 49 | $draw->border(1, '#ff0000'); 50 | }); 51 | ``` 52 | 53 | ### See also 54 | 55 | - [pixel](/v2/api/pixel) 56 | - [line](/v2/api/line) 57 | - [rectangle](/v2/api/rectangle) 58 | - [circle](/v2/api/circle) 59 | - [ellipse](/v2/api/ellipse) 60 | -------------------------------------------------------------------------------- /image/v2/api/psr-response.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "psrResponse()" 3 | title: "Image::psrResponse" 4 | subtitle: "Attach the current image to new PSR-7 HTTP response" 5 | --- 6 | 7 | > public Intervention\Image\Image psrResponse([mixed $format, [int $quality]]) 8 | 9 | Encodes the current image in given **format** and given **image quality** and creates new PSR-7 HTTP response based on image data. 10 | 11 | ### Parameters 12 | 13 | #### format (optional) 14 | Define the encoding format from one of the following formats: 15 | 16 | - **jpg** — return JPEG encoded image data 17 | - **png** — return Portable Network Graphics (PNG) encoded image data 18 | - **gif** — return Graphics Interchange Format (GIF) encoded image data 19 | - **tif** — return Tagged Image File Format (TIFF) encoded image data 20 | - **bmp** — return Bitmap (BMP) encoded image data 21 | - **data-url** — encode current image data in data URI scheme (RFC 2397) 22 | 23 | By default the method will return data encoded in the type of the current image. If no image type is defined yet, data will be encoded as jpeg. 24 | 25 | #### quality (optional) 26 | Define the quality of the encoded image optionally. Data ranging from `0` (poor quality, small file) to `100` (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: `90`. 27 | 28 | ### Return Values 29 | [PSR-7 HTTP response](http://www.php-fig.org/psr/psr-7/) as instance of `GuzzleHttp\Psr7\Response`. 30 | 31 | ### Examples 32 | 33 | ```php 34 | // encode png image as jpg stream 35 | $response = Image::make('public/foo.png')->psrResponse('jpg', 60); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [stream](/v2/api/stream) 41 | - [encode](/v2/api/encode) 42 | - [save](/v2/api/save) 43 | -------------------------------------------------------------------------------- /image/v2/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 2 4 | --- 5 | -------------------------------------------------------------------------------- /image/v2/api/rectangle.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "rectangle()" 3 | title: "Image::rectangle" 4 | subtitle: "Draw a rectangle to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image rectangle(int $x1, int $y1, int $x2, int $y2, [Closure $callback]) 8 | 9 | Draw a colored rectangle on current image with top-left corner on **x,y point 1** and bottom-right corner at **x,y point 2**. Define the overall appearance of the shape by passing a Closure **callback** as an optional parameter. 10 | 11 | ### Parameters 12 | 13 | #### x1 14 | x-coordinate of the top-left point of the rectangle. 15 | 16 | #### y1 17 | y-coordinate of the top-left point of the rectangle. 18 | 19 | #### x2 20 | x-coordinate of the bottom-right point of the rectangle. 21 | 22 | #### y2 23 | y-coordinate of the bottom-right point of the rectangle. 24 | 25 | #### callback (optional) 26 | Define appearance of rectangle. See examples below. Use the following methods to pass details. 27 | 28 | > public Intervention\Image\AbstractShape background(string $color) 29 | 30 | Define the background-color of the rectangle in one of the available [color formats](/v2/getting-started/formats). 31 | 32 | > public Intervention\Image\AbstractShape border(integer $width, string $color) 33 | 34 | Define the border of the rectangle. Set width as pixels in the first and the border-color in one of the available [color formats](/v2/getting-started/formats) as second parameter. 35 | 36 | 37 | ### Return Values 38 | Instance of `Intervention\Image\Image` 39 | 40 | ### Examples 41 | 42 | ```php 43 | // create empty canvas with background color 44 | $img = Image::canvas(100, 100, '#ddd'); 45 | 46 | // draw an empty rectangle border 47 | $img->rectangle(10, 10, 190, 190); 48 | 49 | // draw filled red rectangle 50 | $img->rectangle(5, 5, 195, 195, function ($draw) { 51 | $draw->background('#ff0000'); 52 | }); 53 | 54 | // draw transparent rectangle with 2px border 55 | $img->rectangle(5, 5, 195, 195, function ($draw) { 56 | $draw->background('rgba(255, 255, 255, 0.5)'); 57 | $draw->border(2, '#000'); 58 | }); 59 | ``` 60 | 61 | ### See also 62 | 63 | - [pixel](/v2/api/pixel) 64 | - [line](/v2/api/line) 65 | - [circle](/v2/api/circle) 66 | - [ellipse](/v2/api/ellipse) 67 | - [polygon](/v2/api/polygon) 68 | -------------------------------------------------------------------------------- /image/v2/api/reset.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "reset()" 3 | title: "Image::reset" 4 | subtitle: "Reset current image to a previously saved state" 5 | --- 6 | 7 | > public Intervention\Image\Image reset([string $name]) 8 | 9 | Resets all of the modifications to a state saved previously by [backup](/v2/api/backup) under an optional **name**. 10 | 11 | ### Parameters 12 | 13 | #### name (optional) 14 | The name of the backup in memory. Default: *default* 15 | 16 | 17 | ### Return Values 18 | Instance of `Intervention\Image\Image` 19 | 20 | ### Examples 21 | 22 | ```php 23 | // create an image 24 | $img = Image::make('public/foo.jpg'); 25 | 26 | // backup status 27 | $img->backup(); 28 | 29 | // perform some modifications 30 | $img->resize(320, 240); 31 | $img->invert(); 32 | $img->save('public/small.jpg'); 33 | 34 | // reset image (return to backup state) 35 | $img->reset(); 36 | 37 | // perform other modifications 38 | $img->resize(640, 480); 39 | $img->invert(); 40 | $img->save('public/large.jpg'); 41 | ``` 42 | 43 | ### See also 44 | 45 | - [backup](/v2/api/backup) 46 | -------------------------------------------------------------------------------- /image/v2/api/resize-canvas.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "resizeCanvas()" 3 | title: "Image::resizeCanvas" 4 | subtitle: "Resize the current image boundaries" 5 | --- 6 | 7 | > public Intervention\Image\Image resizeCanvas (int $width, int $height, [string $anchor, [boolean $relative, [mixed $bgcolor]]]) 8 | 9 | Resize the boundaries of the current image to given **width and height**. An **anchor** can be defined to determine from what point of the image the resizing is going to happen. Set the mode to **relative** to add or subtract the given width or height to the actual image dimensions. You can also pass a **background color** for the emerging area of the image. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | The new width in pixels of the image in absolute mode or the amount of pixels to add or subtract from height in relative mode. 15 | 16 | #### height 17 | The new height in pixels of the image in absolute mode or the amount of pixels to add or subtract from height in relative mode. 18 | 19 | #### anchor (optional) 20 | Set a point from where the image resizing is going to happen. For example if you are setting the anchor to ```bottom-left``` this side is pinned and the values of width/height will be added or subtracted to the top-right corner of the image. 21 | 22 | The possible values for this parameter are: 23 | 24 | - `top-left` 25 | - `top` 26 | - `top-right` 27 | - `left` 28 | - `center` (default) 29 | - `right` 30 | - `bottom-left` 31 | - `bottom` 32 | - `bottom-right` 33 | 34 | 35 | #### relative (optional) 36 | Determine that the resizing is going to happen in relative mode. Meaning that the values of width or height will be added or substracted from the current height of the image. Default: `false` 37 | 38 | #### bgcolor (optional) 39 | A background color for the new areas of the image. The background color can be passed in different [color formats](/v2/getting-started/formats). Default: `#ffffff`, transparent if supported by the output format 40 | 41 | ### Return Values 42 | Resized instance of `Intervention\Image\Image` 43 | 44 | ### Examples 45 | 46 | ```php 47 | // create Image from file 48 | $img = Image::make('public/foo.jpg'); 49 | 50 | // resize image canvas 51 | $img->resizeCanvas(300, 200); 52 | 53 | // resize only the width of the canvas 54 | $img->resizeCanvas(300, null); 55 | 56 | // resize only the height of the canvas 57 | $img->resizeCanvas(null, 200); 58 | 59 | // resize the canvas by cutting out bottom right position 60 | $img->resizeCanvas(300, 200, 'bottom-right'); 61 | 62 | // resize the canvas relative by setting the third parameter to true 63 | $img->resizeCanvas(10, -10, 'center', true); 64 | 65 | // set a background-color for the emerging area 66 | $img->resizeCanvas(1280, 720, 'center', false, 'ff00ff'); 67 | ``` 68 | 69 | ### See also 70 | 71 | - [resize](/v2/api/resize) 72 | - [fit](/v2/api/fit) 73 | - [crop](/v2/api/crop) 74 | - [trim](/v2/api/trim) 75 | -------------------------------------------------------------------------------- /image/v2/api/resize.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "resize()" 3 | title: "Image::resize" 4 | subtitle: "Resize the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image resize (integer $width, integer $height, Closure $callback) 8 | 9 | Resizes current image based on given **width** and/or **height**. To constraint the resize command, pass an optional Closure **callback** as third parameter. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | The new width of the image 15 | 16 | #### height 17 | The new height of the image 18 | 19 | #### callback (optional) 20 | 21 | Closure callback defining constraints on the resize. It's possible to constraint the **aspect-ratio** and/or a unwanted **upsizing** of the image. See examples below. 22 | 23 | > public Intervention\Image\Size aspectRatio() 24 | 25 | Constraint the current aspect-ratio of the image. As a shortcut to proportional resizing you can use [widen()](/v2/api/widen) or [heighten()](/v2/api/heighten). 26 | 27 | > public Intervention\Image\Size upsize() 28 | 29 | Keep image from being upsized. 30 | 31 | ### Return Values 32 | Instance of `Intervention\Image\Image` 33 | 34 | ### Examples 35 | 36 | ```php 37 | // create instance 38 | $img = Image::make('public/foo.jpg'); 39 | 40 | // resize image to fixed size 41 | $img->resize(300, 200); 42 | 43 | // resize only the width of the image 44 | $img->resize(300, null); 45 | 46 | // resize only the height of the image 47 | $img->resize(null, 200); 48 | 49 | // resize the image to a width of 300 and constrain aspect ratio (auto height) 50 | $img->resize(300, null, function ($constraint) { 51 | $constraint->aspectRatio(); 52 | }); 53 | 54 | // resize the image to a height of 200 and constrain aspect ratio (auto width) 55 | $img->resize(null, 200, function ($constraint) { 56 | $constraint->aspectRatio(); 57 | }); 58 | 59 | // prevent possible upsizing 60 | $img->resize(null, 400, function ($constraint) { 61 | $constraint->aspectRatio(); 62 | $constraint->upsize(); 63 | }); 64 | 65 | // resize the image so that the largest side fits within the limit; the smaller 66 | // side will be scaled to maintain the original aspect ratio 67 | $img->resize(400, 400, function ($constraint) { 68 | $constraint->aspectRatio(); 69 | $constraint->upsize(); 70 | }); 71 | ``` 72 | 73 | ### See also 74 | 75 | - [widen](/v2/api/widen) 76 | - [heighten](/v2/api/heighten) 77 | - [fit](/v2/api/fit) 78 | - [resizeCanvas](/v2/api/resize-canvas) 79 | - [crop](/v2/api/crop) 80 | - [trim](/v2/api/trim) 81 | -------------------------------------------------------------------------------- /image/v2/api/response.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "response()" 3 | title: "Image::response" 4 | subtitle: "Sends HTTP response with current image attached" 5 | --- 6 | 7 | > public Intervention\Image\Image response([string $format, [integer $quality]]) 8 | 9 | Sends HTTP response with current image in given **format** and **quality**. 10 | 11 | ### Parameters 12 | 13 | #### format (optional) 14 | Define the encoding format from one of the following formats: 15 | 16 | - **jpg** — return JPEG encoded image data 17 | - **png** — return Portable Network Graphics (PNG) encoded image data 18 | - **gif** — return Graphics Interchange Format (GIF) encoded image data 19 | - **tif** — return Tagged Image File Format (TIFF) encoded image data 20 | - **bmp** — return Bitmap (BMP) encoded image data 21 | 22 | By default the response data will be encoded in the type of the current image. If no image type is defined yet, method will return jpeg encoded data. 23 | 24 | #### quality (optional) 25 | Define optionally the quality encoded image data ranging from 0 (poor quality, small file) to 100 (best quality, big file). Default: `90`. 26 | 27 | 28 | ### Return Values 29 | Encoded image data after raw HTTP header is sent. If you are in a **Laravel framework** environment the method will return a `Illuminate\Http\Response` with the corresponding header fields already set. 30 | 31 | ### Examples 32 | 33 | #### Basic Example 34 | 35 | ```php 36 | // create a new empty image resource 37 | $img = Image::canvas(800, 600, '#ff0000'); 38 | 39 | // send HTTP header and output image data 40 | echo $img->response(); 41 | ``` 42 | 43 | #### Laravel Example 44 | 45 | ```php 46 | Route::get('/', function() { 47 | return Image::make('foo/bar.jpg')->response('png'); 48 | }); 49 | ``` 50 | 51 | ### See also 52 | 53 | - [encode](/v2/api/encode) 54 | - [save](/v2/api/save) 55 | - [cache](/v2/api/cache) 56 | -------------------------------------------------------------------------------- /image/v2/api/rotate.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "rotate()" 3 | title: "Image::rotate" 4 | subtitle: "Rotate the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image rotate(float $angle, [string $bgcolor]) 8 | 9 | Rotate the current image counter-clockwise by a given **angle**. Optionally define a **background color** for the uncovered zone after the rotation. 10 | 11 | ### Parameters 12 | 13 | #### angle 14 | The rotation angle in degrees to rotate the image counter-clockwise. 15 | 16 | #### bgcolor (optional) 17 | A background color for the uncovered zone after the rotation. The background color can be passed in different [color formats](/v2/getting-started/formats). Default: `#ffffff`, transparent if supported by the output format 18 | 19 | 20 | ### Return Values 21 | Instance of `Intervention\Image\Image` 22 | 23 | ### Examples 24 | 25 | ```php 26 | // create Image from file 27 | $img = Image::make('public/foo.jpg'); 28 | 29 | // rotate image 45 degrees clockwise 30 | $img->rotate(-45); 31 | ``` 32 | 33 | ### See also 34 | 35 | - [flip](/v2/api/flip) 36 | - [resize](/v2/api/resize) 37 | - [resizeCanvas](/v2/api/resize-canvas) 38 | -------------------------------------------------------------------------------- /image/v2/api/save.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "save()" 3 | title: "Image::save" 4 | subtitle: "Encode and save the current image to a filesystem" 5 | --- 6 | 7 | > public Intervention\Image\Image save([string $path, [int $quality], [string $format]]) 8 | 9 | Save the current state of the image object in a filesystem. Define optionally a certain **path** where the image should be saved. You can also optionally set the **quality** of the image file as second parameter. 10 | 11 | The image type will be defined by the file extension. For example if you pass `foo.jpg` the image will be saved as a JPG file. If there is no extension available, the library will first try to use the MIME type of the image to define the encoding, if this also fails the image will be encoded as JPEG. Optionally you can override this with the format parameter. 12 | 13 | Furthermore the image will always be saved in RGB color mode without an embeded color profile. 14 | 15 | ### Parameters 16 | 17 | #### path (optional) 18 | Path to the file where to write the image data. If the image is created from a existing image in the filesystem and the parameter is not set, the method will try to overwrite the existing file. 19 | 20 | #### quality (optional) 21 | Define optionally the quality of the image. It is normalized for all file types to a range from `0` (poor quality, small file) to `100` (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. The default value is `90`. 22 | 23 | #### format (optional) 24 | By default the format of the saved image is defined by the file extension of the given path. Alternatively it is possible to define the image format by passing one of the [image format extension](/v2/getting-started/formats) as a third parameter. 25 | 26 | 27 | ### Return Values 28 | Instance of `Intervention\Image\Image` 29 | 30 | ### Examples 31 | 32 | ```php 33 | // open and resize an image file 34 | $img = Image::make('public/foo.jpg')->resize(300, 200); 35 | 36 | // save file as jpg with medium quality 37 | $img->save('public/bar.jpg', 60); 38 | 39 | // save the same file as jpg with default quality 40 | $img->save('public/baz.jpg'); 41 | 42 | // save the file in png format 43 | $img->save('public/bar.png'); 44 | 45 | // save the image jpg format defined by third parameter 46 | $img->save('public/foo', 80, 'jpg'); 47 | ``` 48 | 49 | ### See also 50 | 51 | - [make](/v2/api/make) 52 | - [encode](/v2/api/encode) 53 | -------------------------------------------------------------------------------- /image/v2/api/sharpen.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "sharpen()" 3 | title: "Image::sharpen" 4 | subtitle: "Sharpen the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image sharpen([integer $amount]) 8 | 9 | Sharpen current image with an optional **amount**. Use values between `0` and `100`. 10 | 11 | ### Parameters 12 | 13 | #### amount (optional) 14 | The amount of the sharpening strength. Method accepts values between `0` and `100`. Default: `10` 15 | 16 | ### Return Values 17 | Instance of `Intervention\Image\Image` 18 | 19 | ### Examples 20 | 21 | ```php 22 | // create new Intervention Image 23 | $img = Image::make('public/foo.jpg'); 24 | 25 | // sharpen image 26 | $img->sharpen(15); 27 | ``` 28 | 29 | ### See also 30 | 31 | - [blur](/v2/api/blur) 32 | -------------------------------------------------------------------------------- /image/v2/api/stream.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "stream()" 3 | title: "Image::stream" 4 | subtitle: "Encoded current image and return PSR-7 stream" 5 | --- 6 | 7 | > public Intervention\Image\Image stream([mixed $format, [int $quality]]) 8 | 9 | Encodes the current image in given **format** and given **image quality** and creates new PSR-7 stream based on image data. 10 | 11 | ### Parameters 12 | 13 | #### format (optional) 14 | Define the encoding format from one of the following formats: 15 | 16 | - **jpg** — return JPEG encoded image data 17 | - **png** — return Portable Network Graphics (PNG) encoded image data 18 | - **gif** — return Graphics Interchange Format (GIF) encoded image data 19 | - **tif** — return Tagged Image File Format (TIFF) encoded image data 20 | - **bmp** — return Bitmap (BMP) encoded image data 21 | - **data-url** — encode current image data in data URI scheme (RFC 2397) 22 | 23 | By default the method will return data encoded in the type of the current image. If no image type is defined yet, data will be encoded as jpeg. 24 | 25 | #### quality (optional) 26 | Define the quality of the encoded image optionally. Data ranging from `0` (poor quality, small file) to `100` (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: `90`. 27 | 28 | ### Return Values 29 | [PSR-7 stream](http://www.php-fig.org/psr/psr-7/) as instance of `GuzzleHttp\Psr7\Stream`. 30 | 31 | ### Examples 32 | 33 | ```php 34 | // encode png image as jpg stream 35 | $stream = Image::make('public/foo.png')->stream('jpg', 60); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [psrResponse](/v2/api/psr-response) 41 | - [encode](/v2/api/encode) 42 | - [save](/v2/api/save) 43 | -------------------------------------------------------------------------------- /image/v2/api/text.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "text()" 3 | title: "Image::text" 4 | subtitle: "Write text to the current image" 5 | --- 6 | 7 | > public Intervention\Image\Image text(string $text, [integer $x, [integer $y, [Closure $callback]]]) 8 | 9 | Write a **text** string to the current image at an optional **x,y basepoint position**. You can define more details like font-size, font-file and alignment via a **callback** as the fourth parameter. 10 | 11 | ### Parameters 12 | 13 | #### text 14 | The text string that will be written to the image. 15 | 16 | #### x (optional) 17 | x-ordinate defining the basepoint of the first character. Default: `0` 18 | 19 | #### y (optional) 20 | y-ordinate defining the basepoint of the first character. Default: `0` 21 | 22 | #### callback (optional) 23 | Closure callback on the font object to define more optional details. Use the following methods to pass details. See examples of the callback usage below. 24 | 25 | > public Intervention\Image\Font file(string $filepath) 26 | 27 | Set path to a True Type Font file or a integer value between 1 and 5 for one of the GD library internal fonts. Default: `1` 28 | 29 | > public Intervention\Image\Font size(integer $size) 30 | 31 | Set font size in pixels. **Font sizing is only available if a font file is set and will be ignored otherwise.** Default: `12` 32 | 33 | > public Intervention\Image\Font color(mixed $color) 34 | 35 | Set color of the text in one of the available [color formats](/v2/getting-started/formats). Default: `#000000` 36 | 37 | > public Intervention\Image\Font align(string $align) 38 | 39 | Set horizontal text alignment relative to given basepoint. Possible values are left, right and center. Default: `left` 40 | 41 | > public Intervention\Image\Font valign(string $valign) 42 | 43 | Set vertical text alignment relative to given basepoint. Possible values are top, bottom and middle. Default: `bottom` 44 | 45 | > public Intervention\Image\Font angle(integer $angle) 46 | 47 | Set rotation angle of text in degrees. Text will be rotated counter-clockwise around the vertical and horizontal aligned point. **Rotation is only available if a font file is set and will be ignored otherwise**. Default: no rotation 48 | 49 | ### Return Values 50 | Instance of `Intervention\Image\Image` 51 | 52 | 53 | 54 | ### Examples 55 | 56 | ```php 57 | // create Image from file 58 | $img = Image::make('public/foo.jpg'); 59 | 60 | // write text 61 | $img->text('The quick brown fox jumps over the lazy dog.'); 62 | 63 | // write text at position 64 | $img->text('The quick brown fox jumps over the lazy dog.', 120, 100); 65 | 66 | // use callback to define details 67 | $img->text('foo', 0, 0, function($font) { 68 | $font->file('foo/bar.ttf'); 69 | $font->size(24); 70 | $font->color('#fdf6e3'); 71 | $font->align('center'); 72 | $font->valign('top'); 73 | $font->angle(45); 74 | }); 75 | 76 | // draw transparent text 77 | $img->text('foo', 0, 0, function($font) { 78 | $font->color([255, 255, 255, 0.5]); 79 | }); 80 | ``` 81 | -------------------------------------------------------------------------------- /image/v2/api/trim.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "trim()" 3 | title: "Image::trim" 4 | subtitle: "Trim away parts by color " 5 | --- 6 | 7 | > public Intervention\Image\Image trim( [string $base, [array $away, [int $tolerance, [int $feather]]]] ) 8 | 9 | Trim away image space in given color. Define an optional **base** to pick a color at a certain position and borders that should be trimmed **away**. You can also set an optional **tolerance** level, to trim similar colors and add a **feathering** border around the trimed image. 10 | 11 |
Note: Resource intensive with GD driver. Use with care.
12 | 13 | ### Parameters 14 | 15 | #### base 16 | Define the point from where the trimming color is picked. For example if you set this parameter to `bottom-right`, all color will be trimmed away that is equal to the color in the bottom-left corner of the image. 17 | 18 | Possible values are: 19 | 20 | - `top-left` (default) 21 | - `bottom-right` 22 | - `transparent` 23 | 24 | #### away (optional) 25 | Border(s) that should be trimmed away. You can add multiple borders. as an array of values. Possible values are: 26 | 27 | - `top` 28 | - `bottom` 29 | - `left` 30 | - `right` 31 | 32 | By default the trimming is performed on all borders. 33 | 34 | #### tolerance (optional) 35 | Define a percentaged tolerance level between 0 and 100 to trim away similar color values. Default: `0` 36 | 37 | #### feather (optional) 38 | Sometimes it may be useful to leave a untouched "border" around an object while trimming. Especially when trimming non-solid backgrounds you can expand (positive value) or contract (negative value) the space around the trimed object by a certain amount of pixels. Default: `0` 39 | 40 | 41 | ### Return Values 42 | Instance of `Intervention\Image\Image` 43 | 44 | ### Examples 45 | 46 | ```php 47 | // trim image (by default on all borders with top-left color) 48 | Image::make('public/foo.jpg')->trim(); 49 | 50 | // trim image (on all borders with bottom-right color) 51 | Image::make('public/foo.jpg')->trim('bottom-right'); 52 | 53 | // trim image (only top and bottom with transparency) 54 | Image::make('public/foo.jpg')->trim('transparent', ['top', 'bottom']); 55 | 56 | // trim image (only left side top-left color) 57 | Image::make('public/foo.jpg')->trim('top-left', 'left'); 58 | 59 | // trim image on all borders (with 40% tolerance) 60 | Image::make('public/foo.jpg')->trim('top-left', null, 40); 61 | 62 | // trim image and leave a border of 50px by feathering 63 | Image::make('public/foo.jpg')->trim('top-left', null, 25, 50); 64 | ``` 65 | 66 | ### See also 67 | 68 | - [resize](/v2/api/resize) 69 | - [resizeCanvas](/v2/api/resize-canvas) 70 | - [fit](/v2/api/fit) 71 | - [crop](/v2/api/crop) 72 | -------------------------------------------------------------------------------- /image/v2/api/widen.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "widen()" 3 | title: "Image::widen" 4 | subtitle: "Resize current image proportionally to given width" 5 | --- 6 | 7 | > public Intervention\Image\Image widen(integer $width, [Closure $callback]) 8 | 9 | Resizes the current image to new **width**, constraining aspect ratio. Pass an optional Closure **callback** as third parameter, to apply additional constraints like preventing possible upsizing. 10 | 11 | ### Parameters 12 | 13 | #### width 14 | The new width of the image 15 | 16 | #### callback (optional) 17 | Closure callback defining constraint to prevent unwanted **upsizing** of the image. See examples below. 18 | 19 | > public Intervention\Image\Size upsize() 20 | 21 | Keep image from being upsized. 22 | 23 | ### Return Values 24 | Instance of `Intervention\Image\Image` 25 | 26 | ### Examples 27 | 28 | ```php 29 | // resize image to new width 30 | $img = Image::make('public/foo.jpg')->widen(300); 31 | 32 | // resize image to new width but do not exceed original size 33 | $img = Image::make('public/foo.jpg')->widen(300, function ($constraint) { 34 | $constraint->upsize(); 35 | }); 36 | ``` 37 | 38 | ### See also 39 | 40 | - [heighten](/v2/api/heighten) 41 | - [resize](/v2/api/resize) 42 | -------------------------------------------------------------------------------- /image/v2/api/width.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "width()" 3 | title: "Image::width" 4 | subtitle: "Get width of current image" 5 | --- 6 | 7 | > public Intervention\Image\Image width() 8 | 9 | Returns the width in pixels of the current image. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Return Values 16 | Width of current image in pixels as integer 17 | 18 | ### Examples 19 | 20 | ```php 21 | // read width of image 22 | $width = Image::make('public/foo.jpg')->width(); 23 | ``` 24 | 25 | ### See also 26 | 27 | - [height](/v2/api/height) 28 | -------------------------------------------------------------------------------- /image/v2/getting-started/configuration.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Configuration" 3 | subtitle: "Set up Intervention Image" 4 | sort: 2 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Driver Configuration 10 | 11 | Currently Intervention Image supports two Image processing extensions. Make sure you have one of these installed in your PHP environment, before you start. 12 | 13 | - **GD** 14 | - **Imagick** 15 | 16 | You're able to configure Intervention Image to use one of these libraries for all its operations. Just pass the configuration as an array directly into the ImageManager. 17 | 18 | #### Example 19 | 20 | ```php 21 | // include composer autoload 22 | require 'vendor/autoload.php'; 23 | 24 | // import the Intervention Image Manager Class 25 | use Intervention\Image\ImageManager; 26 | 27 | // create an image manager instance with favored driver 28 | $manager = new ImageManager(['driver' => 'imagick']); 29 | 30 | // to finally create image instances 31 | $image = $manager->make('public/foo.jpg')->resize(300, 200); 32 | ``` 33 | 34 | You might also use the static version of ImageManager as shown in the example below. 35 | 36 | #### Static Example 37 | 38 | ```php 39 | // include composer autoload 40 | require 'vendor/autoload.php'; 41 | 42 | // import the Intervention Image Manager Class 43 | use Intervention\Image\ImageManagerStatic as Image; 44 | 45 | // configure with favored image driver (gd by default) 46 | Image::configure(['driver' => 'imagick']); 47 | 48 | // and you are ready to go ... 49 | $image = Image::make('public/foo.jpg')->resize(300, 200); 50 | ``` 51 | 52 | ## Memory Settings 53 | 54 | Image manipulation in PHP is a very memory consuming task. Since most tasks in PHP don't exhaust default memory limits, you have to make sure your PHP configuration is able to allocate enough memory to handle large images. 55 | 56 | The following php.ini directives are important. 57 | 58 | ### memory_limit 59 | 60 | Sets a maximum amount of memory in bytes that a script is allowed to allocate. Resizing a 3000 x 2000 pixel image to 300 x 200 may take up to 32MB memory. 61 | 62 | ### upload_max_filesize 63 | 64 | If you're planing to upload large images, verify that this setting for the maximum size of file uploads fits your needs. 65 | 66 | Read more in the official PHP documentation for: 67 | 68 | * [memory_limit](http://www.php.net/manual/en/ini.core.php#ini.memory-limit) 69 | * [upload_max_filesize](http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize) 70 | 71 | It's possible to set these directives in your [php.ini](http://www.php.net/manual/en/ini.core.php) or at runtime with [ini_set](http://www.php.net/manual/en/function.ini-set.php). 72 | 73 | 74 | 75 | ## Configuration in Laravel 76 | 77 | If you're using Laravel, you can pull a configuration file into your application by running the following artisan command. 78 | 79 | ### Publish configuration in Laravel 5 80 | 81 | > $ php artisan vendor:publish 82 | 83 | ### Publish configuration in Laravel 4 84 | 85 | > $ php artisan config:publish intervention/image 86 | 87 | In Laravel 5 applications the configuration file is copied to ```config/image.php```, in older Laravel 4 applications you will find the file at ```app/config/packages/intervention/image/config.php```. With this copy you can alter the image driver settings for you application locally and define which library should be used by all commands.. 88 | 89 | ```php 90 | 'driver' => 'imagick' 91 | ``` 92 | 93 | Currently you can choose between `gd` and `imagick` support. 94 | -------------------------------------------------------------------------------- /image/v2/getting-started/formats.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Supported Formats" 3 | subtitle: "Image & color formats" 4 | sort: 4 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Image Formats 10 | 11 | The readable image formats depend on the choosen driver (GD or Imagick) and your local configuration. By default Intervention Image currently supports the following major formats. 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 JPEGPNGGIFTIFBMPICOPSDWebP
GD✔️✔️✔️-✔️ **--✔️ *
Imagick✔️✔️✔️✔️✔️✔️✔️✔️ *
48 | 49 | * For WebP support **GD** driver must be used with PHP 5 >= 5.5.0 or PHP 7 in order to use [imagewebp()](http://php.net/manual/en/function.imagewebp.php). If **Imagick** is used, it must be compiled with libwebp for WebP support. 50 | 51 | ** For BMP support **GD** driver must be used with PHP >= 7.2.0 or PHP 8 in order to use [imagewebp()](https://www.php.net/manual/en/function.imagebmp.php). 52 | 53 | See documentation of [make](/v2/api/make) method to see how to read image formats from different sources, respectively [encode](/v2/api/encode) and [save](/v2/api/save) to learn how to output images. 54 | 55 | ## Color Formats 56 | 57 | Intervention Image supports four ways to define colors for its methods. 58 | 59 | ### Integer Format 60 | By default the [pickColor](/v2/api/pick-color) method returns the RGB value as integer. You can also pass a color in this format to all other methods. 61 | 62 | #### Examples 63 | 64 | ```php 65 | // pick color and fill image 66 | $color = Image::make('public/foo.jpg')->pickColor(10, 10); 67 | $img->fill($color); 68 | 69 | // pass colors of the GD Library 70 | $im = imagecreatefrompng('public/foo.jpg'); 71 | $rgb = imagecolorat($im, 10, 15); 72 | $img->fill($rgb); 73 | ``` 74 | 75 | ### Array Format 76 | 77 | Pass the RGB integers of a color as a PHP array with or without an alpha value between 1 (opaque) and 0 (full transparency). 78 | 79 | #### Examples 80 | 81 | ```php 82 | // color in array format 83 | $img->fill([255, 0, 0]); 84 | 85 | // color in array format with alpha value 86 | $img->fill([255, 255, 255, 0.5]); 87 | ``` 88 | 89 | ### Hexadecimal Format 90 | You can pass colors as a hex triplet used normally in HTML and CSS. It's possible to use six-digit format as well as the shorthand form. 91 | 92 | #### Examples 93 | 94 | ```php 95 | // shorthand hex color 96 | $img->fill('#ccc'); 97 | 98 | // six-digit hex color 99 | $img->fill('#cccccc'); 100 | 101 | // works without prefix 102 | $img->fill('cccccc'); 103 | ``` 104 | 105 | ### RGB & RGBA string format 106 | RGB string values in functional notations are also supported. If you want to include an **alpha** value use the RGBA format like in the following example. 107 | 108 | #### Examples 109 | 110 | ```php 111 | // rgb color value in integer range 112 | $img->fill('rgb(255, 0, 0)'); 113 | 114 | // rgba color value with alpha 115 | $img->fill('rgba(255, 0, 0, 1)'); 116 | 117 | // rgba color value with transparent alpha 118 | $img->fill('rgba(0, 0, 0, 0.5)'); 119 | ``` 120 | -------------------------------------------------------------------------------- /image/v2/getting-started/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Easy installation via Composer" 4 | sort: 1 5 | --- 6 | 7 | [TOC] 8 | 9 | ### System Requirements 10 | 11 | Intervention Image requires the following components to work correctly. 12 | 13 | - PHP >= 5.4 14 | - Fileinfo Extension 15 | 16 | And **one of** the following image libraries. 17 | 18 | - GD Library (>=2.0) … **or** … 19 | - Imagick PHP extension (>=6.5.7) 20 | 21 | ## Installation 22 | 23 | The best way to install Intervention Image is quickly and easily with [Composer](https://getcomposer.org/). 24 | 25 | To install the most recent version, run the following command. 26 | 27 | ```bash 28 | composer require intervention/image:^2 29 | ``` 30 | 31 | Now your ```composer.json``` has been updated automatically and you're able to require the just created ```vendor/autoload.php``` file to PSR-4 autoload the library. 32 | 33 | The next step is to decide, if you want to integrate Intervention Image into the **Laravel framework**. If you want to use the library with Laravel, just skip the following step and continue with the description of [Laravel Integration](#integration-in-laravel). 34 | 35 | 36 | ## Usage 37 | 38 | Intervention Image doesn't require Laravel or any other framework at all. If you want to use it as is, you just have to require the composer autoload file to instantiate image objects as shown in the following example. 39 | 40 | #### Example 41 | 42 | ```php 43 | // include composer autoload 44 | require 'vendor/autoload.php'; 45 | 46 | // import the Intervention Image Manager Class 47 | use Intervention\Image\ImageManager; 48 | 49 | // create an image manager instance with favored driver 50 | $manager = new ImageManager(['driver' => 'imagick']); 51 | 52 | // to finally create image instances 53 | $image = $manager->make('public/foo.jpg')->resize(300, 200); 54 | ``` 55 | 56 | You might also use the static version of ImageManager as shown in the example below. 57 | 58 | #### Static Example 59 | 60 | ```php 61 | // include composer autoload 62 | require 'vendor/autoload.php'; 63 | 64 | // import the Intervention Image Manager Class 65 | use Intervention\Image\ImageManagerStatic as Image; 66 | 67 | // configure with favored image driver (gd by default) 68 | Image::configure(['driver' => 'imagick']); 69 | 70 | // and you are ready to go ... 71 | $image = Image::make('public/foo.jpg')->resize(300, 200); 72 | ``` 73 | 74 | 75 | ## Integration in Laravel 76 | 77 | Intervention Image has optional support for [Laravel](https://www.laravel.com) and comes with a **Service Provider and Facades** for easy integration. The `vendor/autoload.php` is included by Laravel, so you don't have to require or autoload manually. Just see the instructions below. 78 | 79 | After you have installed Intervention Image, open your Laravel config file ```config/app.php``` and add the following lines. 80 | 81 | In the ```$providers``` array add the service providers for this package. 82 | 83 | ``` 84 | Intervention\Image\ImageServiceProvider::class 85 | ``` 86 | 87 | Add the facade of this package to the ```$aliases``` array. 88 | 89 | ```php 90 | 'Image' => Intervention\Image\Facades\Image::class 91 | ``` 92 | 93 | Now the Image Class will be auto-loaded by Laravel. 94 | 95 | 96 | ### Configuration 97 | 98 | By default Intervention Image uses PHP's GD library extension to process all images. If you want to switch to Imagick, you can pull a configuration file into your application by running one of the following artisan command. 99 | 100 | #### Publish configuration in Laravel 101 | 102 | ```bash 103 | php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravelRecent" 104 | ```` 105 | 106 | 107 | #### Publish configuration in Laravel <= 4 108 | 109 | ```bash 110 | php artisan config:publish intervention/image 111 | ``` 112 | In recent Laravel applications the configuration file is copied to `config/image.php`, in older Laravel 4 applications you will find the file at ```app/config/packages/intervention/image/config.php```. With this copy you can alter the image driver settings for you application locally. 113 | 114 | #### Example 115 | 116 | ```php 117 | // usage inside a laravel route 118 | Route::get('/', function() { 119 | $img = Image::make('foo.jpg')->resize(300, 200); 120 | return $img->response('jpg'); 121 | }); 122 | ``` 123 | 124 | 125 | -------------------------------------------------------------------------------- /image/v2/getting-started/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "Introduction" 3 | title: "Intervention Image" 4 | subtitle: "PHP Image Manipulation" 5 | sort: 0 6 | --- 7 | 8 | Intervention Image is an open source **PHP image handling and manipulation** library. It provides an easier and expressive way to create, edit, and compose images and supports currently the three most common image processing libraries **GD Library**, **Imagick** or **libvips**. 9 | 10 | The class is written to make PHP image manipulating easier and more expressive. No matter if you want to create image thumbnails, watermarks or format large image files Intervention Image helps you to manage every task in an easy way with as little lines of code as possible. 11 | 12 | The library follows the FIG standard **PSR-2** to ensure a high level of interoperability between shared PHP code and is fully **unit-tested**. 13 | 14 | ### Getting started 15 | 16 | The library requires at least **PHP version 5.4** and comes with **Laravel Facades and Service Providers** to simplify the optional framework integration. 17 | 18 | - [Read the installation guide](/v2/getting-started/installation) 19 | - [Read about Laravel integration](/v2/getting-started/installation#integration-in-laravel) 20 | 21 | ### Basic Examples 22 | 23 | ```php 24 | // open an image file 25 | $img = Image::make('public/foo.jpg'); 26 | 27 | // now you are able to resize the instance 28 | $img->resize(320, 240); 29 | 30 | // and insert a watermark for example 31 | $img->insert('public/watermark.png'); 32 | 33 | // finally we save the image as a new file 34 | $img->save('public/bar.jpg'); 35 | ``` 36 | 37 | #### Method chaining 38 | 39 | Do the same in one line of code. 40 | 41 | ```php 42 | $img = Image::make('public/foo.jpg')->resize(320, 240)->insert('public/watermark.png'); 43 | ``` 44 | 45 | To view more code examples read the documentation on the individual methods [make](/v2/api/make), [resize](/v2/api/resize), [insert](/v2/api/insert), [save](/v2/api/save) and the introduction to [basic usage](/v2/usage/overview). 46 | -------------------------------------------------------------------------------- /image/v2/getting-started/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /image/v2/getting-started/upgrade.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "Upgrade from 1.x" 3 | title: "Upgrade Guide" 4 | subtitle: "Upgrade from Intervention Image 1.x to 2.x" 5 | sort: 3 6 | --- 7 | 8 | [TOC] 9 | 10 | Although I tried to keep the update to Version 2.x of Intervention Image as compatible as possible, some things have changed. Some methods became redundant, other things have been simplified and therefore had to change. 11 | 12 | ## New Features 13 | 14 | - Additional support of PHP's Imagick extension 15 | - Sharpening Images 16 | - Auto Orientating 17 | - Image Filter architecture 18 | 19 | In order to keep your application compatible, you need to keep in mind the following changes, when upgrading. 20 | 21 | ### New Methods 22 | 23 | - [width()](/v2/api/width) retrieves current width of image. 24 | - [height()](/v2/api/height) retrieves current height of image. 25 | - [sharpen()](/v2/api/sharpen) applies sharpen filter to image. 26 | - [orientate()](/v2/api/orientate) auto-adjusts image orientation. 27 | - [filter()](/v2/api/filter) applies filter to an image. 28 | - [getCore()](/v2/api/get-core) get resource of image driver (Imagick object or GD resource). 29 | 30 | ## API changes 31 | 32 | ### Changed Method names 33 | 34 | - [fit()](/v2/api/fit) replaces the old ```grab()``` method. 35 | 36 | ### Changed Arguments on methods 37 | 38 | - Method [gamma()](/v2/api/gamma) now only accepts one argument for gamma correction. 39 | - Changed arguments for [resize()](/v2/api/resize) method. Now uses callback to define further options. 40 | - Changed arguments for [circle()](/v2/api/circle) method. Now uses callback to define further options. 41 | - Changed arguments for [ellipse()](/v2/api/ellipse) method. Now uses callback to define further options. 42 | - Changed arguments for [line()](/v2/api/line) method. Now uses callback to define further options. 43 | - Changed arguments for [rectangle()](/v2/api/rectangle) method. Now uses callback to define further options. 44 | 45 | ### Removed methods 46 | 47 | - ```open()``` no longer exists, use [make()](/v2/api/make) instead. 48 | - ```raw()``` no longer exists, use [make()](/v2/api/make) instead. 49 | - ```grayscale()``` no longer exists, use [greyscale()](/v2/api/greyscale) instead. 50 | 51 | ### Removed properties 52 | 53 | - ```width``` property has been removed, use [width()](/v2/api/width) instead. 54 | - ```height``` property has been removed, use [height()](/v2/api/height) instead. 55 | 56 | ### Other 57 | 58 | - To keep naming consistent the filename of the configuration file for *intervention/imagecache* was renamed from `config/imagecache.php` to `config/config.php`. 59 | - For standalone use instantiate objects from `Intervention\Image\ImageManagerStatic` instead of `Intervention\Image\Image`. ([See example](/v2/getting-started/installation)) 60 | -------------------------------------------------------------------------------- /image/v2/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 2" 3 | status: "eol" 4 | --- 5 | -------------------------------------------------------------------------------- /image/v2/usage/cache.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Image Caching" 3 | subtitle: "Caching of image operations" 4 | sort: 3 5 | --- 6 | 7 | The optional package [Intervention Image Cache](https://packagist.org/packages/intervention/imagecache) extends the package to be capable of image caching. 8 | 9 | The caching library uses the [Illuminate/Cache](https://github.com/illuminate/cache/) package which is part of Laravel and can be easily integrated into the [Laravel Framework](http://laravel.com). Based on your Laravel cache configuration you are able to choose between Filesystem, Database, Memcached or Redis for the temporary buffer store. 10 | 11 | The principle is simple. Once the caching package is installed, you are able to call the static cache method. Every method call to the Intervention Image class is captured and checked by the caching interface. If this particular sequence of operations already have taken place, the data will be loaded directly from the cache instead of a resource-intensive GD operation. 12 | 13 | ## Installation 14 | 15 | Require the caching package via Composer by running the following command: 16 | 17 | > $ php composer.phar require intervention/imagecache 18 | 19 | Now you are able to require the vendor/autoload.php file to PSR-4 autoload the library. 20 | 21 | ## Usage 22 | 23 | Simply pass every manipulation operation as a Closure callback: 24 | 25 | ```php 26 | // pass calls to image cache 27 | $img = Image::cache(function($image) { 28 | $image->make('public/foo.jpg')->resize(300, 200)->greyscale(); 29 | }); 30 | ``` 31 | 32 | Read the [cache()](/v2/api/cache) method documentation to find out more about the possibilities. 33 | 34 | To take the caching one step further, take a look at [URL based image manipulation](/v2/usage/url-manipulation). 35 | -------------------------------------------------------------------------------- /image/v2/usage/filters.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Image Filters" 3 | subtitle: "Bundle image operations in classes" 4 | sort: 2 5 | --- 6 | 7 | Image Filters in Intervention Image give you the useful possibility to group image transformations commands into a dedicated object. This object defines which command, in which order and with which arguments should be called on an image instance. 8 | 9 | Intervention Image provides the basic ```Intervention\Image\Filters\FilterInterface```, which all filters need to implement. 10 | 11 | Once you have created your own filters, you can apply them using the [filter()](/v2/api/filter) method. 12 | 13 | #### Applying the demo filter 14 | 15 | ```php 16 | // init new image instance 17 | $img = Image::make('foo.jpg'); 18 | 19 | // apply filter 20 | $img->filter(new DemoFilter(45)); 21 | ``` 22 | 23 | Take a look at the example of the DemoFilter ```src/Intervention/Image/Filters/DemoFilter.php``` which combines a greyscale/pixelate effect. 24 | 25 | #### DemoFilter Example 26 | 27 | ```php 28 | size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE; 54 | } 55 | 56 | /** 57 | * Applies filter effects to given image 58 | * 59 | * @param Intervention\Image\Image $image 60 | * @return Intervention\Image\Image 61 | */ 62 | public function applyFilter(\Intervention\Image\Image $image) 63 | { 64 | $image->pixelate($this->size); 65 | $image->greyscale(); 66 | 67 | return $image; 68 | } 69 | } 70 | ``` 71 | -------------------------------------------------------------------------------- /image/v2/usage/http-response.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "HTTP Responses" 3 | subtitle: "Transform an image into a HTTP response" 4 | sort: 1 5 | --- 6 | 7 | The easiest way to return an image directly to the users browser, is to output the [response()](/v2/api/response) method. It will automatically send HTTP headers according to the currently image and output encoded image data. 8 | 9 | #### Sending a HTTP response 10 | 11 | ```php 12 | // create a new image resource 13 | $img = Image::canvas(800, 600, '#ff0000'); 14 | 15 | // send HTTP header and output image data 16 | echo $img->response('jpg', 70); 17 | ``` 18 | 19 | #### Sending HTTP responses manually 20 | 21 | ```php 22 | // create a new image resource 23 | $img = Image::canvas(800, 600, '#ff0000'); 24 | 25 | // send HTTP header and output image data 26 | header('Content-Type: image/png'); 27 | echo $img->encode('png'); 28 | ``` 29 | 30 | 31 | Read more about HTTP responses in the [api documentation](/v2/api/response). 32 | 33 | ## HTTP responses in Laravel Applications 34 | 35 | In Laravel applications it is almost the same thing, apart from that you can return the method's output directly from your route. 36 | 37 | #### Sending a HTTP response in Laravel 38 | 39 | ```php 40 | Route::get('/', function() 41 | { 42 | $img = Image::canvas(800, 600, '#ff0000'); 43 | 44 | return $img->response(); 45 | }); 46 | ``` 47 | 48 | #### Attaching images to a HTTP response in Laravel Applications 49 | 50 | ```php 51 | Route::get('/', function() 52 | { 53 | $img = Image::canvas(800, 600, '#ff0000'); 54 | 55 | // create response and add encoded image data 56 | $response = Response::make($img->encode('png')); 57 | 58 | // set content-type 59 | $response->header('Content-Type', 'image/png'); 60 | 61 | // output 62 | return $response; 63 | }); 64 | ``` 65 | 66 | -------------------------------------------------------------------------------- /image/v2/usage/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage Overview" 3 | subtitle: "Overview of the main use cases" 4 | sort: 0 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Basic Usage 10 | 11 | #### Example 12 | 13 | ```php 14 | // include composer autoload 15 | require 'vendor/autoload.php'; 16 | 17 | // import the Intervention Image Manager Class 18 | use Intervention\Image\ImageManager; 19 | 20 | // create an image manager instance with favored driver 21 | $manager = new ImageManager(['driver' => 'imagick']); 22 | 23 | // to finally create image instances 24 | $image = $manager->make('public/foo.jpg')->resize(300, 200); 25 | ``` 26 | 27 | You might also use the static version of ImageManager as shown in the example below. 28 | 29 | #### Static Example 30 | 31 | ```php 32 | // include composer autoload 33 | require 'vendor/autoload.php'; 34 | 35 | // import the Intervention Image Manager Class 36 | use Intervention\Image\ImageManagerStatic as Image; 37 | 38 | // configure with favored image driver (gd by default) 39 | Image::configure(['driver' => 'imagick']); 40 | 41 | // and you are ready to go ... 42 | $image = Image::make('public/foo.jpg')->resize(300, 200); 43 | ``` 44 | 45 | You can read more detailed information about [installation](/v2/getting-started/installation) and [configuration](/v2/getting-started/configuration). 46 | 47 | ## Reading Images 48 | 49 | Intervention Image makes it super easy to read images. The Library takes away any annoying work, the only thing you have to do is to give a file path to the method [make()](/v2/api/make). 50 | 51 | #### Read image from file 52 | 53 | ```php 54 | $img = Image::make('foo/bar/baz.jpg'); 55 | ``` 56 | 57 | The method is highly variable. It not only reads filepaths but also the following input formats. 58 | 59 | - Path of the image in filesystem. 60 | - URL of an image (```allow_url_fopen``` must be enabled). 61 | - Binary image data. 62 | - Data-URL encoded image data. 63 | - Base64 encoded image data. 64 | - PHP resource of type gd. (when using GD driver) 65 | - Imagick instance (when using Imagick driver) 66 | - Intervention\Image\Image instance 67 | - SplFileInfo instance (To handle Laravel file uploads via Symfony\Component\HttpFoundation\File\UploadedFile) 68 | 69 | See more examples to initiate image instances in the [api documentation](/v2/api/make). 70 | 71 | ## Creating Images 72 | 73 | If you want to create a new empty image instance you can call the [canvas()](/v2/api/canvas) method with given width and height. Optionally it's possible to define a background-color, if not passed the default the canvas background is transparent. 74 | 75 | #### Creating new images with background color 76 | 77 | ```php 78 | $img = Image::canvas(800, 600, '#ccc'); 79 | ``` 80 | 81 | See more examples to create new image instances in the [api documentation](/v2/api/canvas). 82 | 83 | ## Editing Images 84 | 85 | After you initiated a new image instance with [make()](/v2/api/make) or [canvas()](/v2/api/canvas), you can use the whole palette of manipulation methods on the instance. 86 | 87 | Usually each command returns a modified instance of Intervention\Image\Image, so you are able to chain methods. 88 | 89 | #### Method chaining 90 | 91 | ```php 92 | $img = Image::make('foo.jpg')->resize(320, 240)->insert('watermark.png'); 93 | ``` 94 | 95 | Take a look at some of the methods in the following list. 96 | 97 | ### Resizing Images 98 | 99 | - [resize()](/v2/api/resize) 100 | - [widen()](/v2/api/widen) 101 | - [heighten()](/v2/api/heighten) 102 | - [fit()](/v2/api/fit) 103 | - [resizeCanvas()](/v2/api/resize-canvas) 104 | - [crop()](/v2/api/crop) 105 | - [trim()](/v2/api/trim) 106 | 107 | ### Adjusting Images 108 | 109 | - [gamma()](/v2/api/gamma) 110 | - [brightness()](/v2/api/brightness) 111 | - [contrast()](/v2/api/contrast) 112 | - [colorize()](/v2/api/colorize) 113 | - [greyscale()](/v2/api/greyscale) 114 | - [invert()](/v2/api/invert) 115 | - [mask()](/v2/api/mask) 116 | - [flip()](/v2/api/flip) 117 | 118 | ### Applying Effects 119 | 120 | - [filter()](/v2/api/filter) 121 | - [pixelate()](/v2/api/pixelate) 122 | - [rotate()](/v2/api/rotate) 123 | - [blur()](/v2/api/blur) 124 | 125 | ### Drawing 126 | 127 | - [text()](/v2/api/text) 128 | - [pixel()](/v2/api/pixel) 129 | - [line()](/v2/api/line) 130 | - [rectangle()](/v2/api/rectangle) 131 | - [circle()](/v2/api/circle) 132 | - [ellipse()](/v2/api/ellipse) 133 | 134 | ### Retrieving Information 135 | 136 | - [width()](/v2/api/width) 137 | - [height()](/v2/api/height) 138 | - [mime()](/v2/api/mime) 139 | - [exif()](/v2/api/exif) 140 | - [iptc()](/v2/api/iptc) 141 | 142 | 143 | See the **api documentation** for the whole list of commands. 144 | 145 | ## Image Output 146 | 147 | To create actually image data from an image object, you can access methods like [encode](/v2/api/encode) to create encoded image data or use [save](/v2/api/save) to write an image into the filesystem. It's also possible to send a HTTP [response](/v2/api/response) with current image data. 148 | 149 | #### Save an image in filesystem 150 | 151 | ```php 152 | Image::make('foo.jpg')->resize(300, 200)->save('bar.jpg'); 153 | ``` 154 | 155 | Read more about [image HTTP responses](/v2/usage/http-response). 156 | 157 | ### Outputting Image data 158 | 159 | - [encode()](/v2/api/encode) 160 | - [save()](/v2/api/save) 161 | - [response()](/v2/api/response) 162 | 163 | -------------------------------------------------------------------------------- /image/v2/usage/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /image/v2/usage/uploads.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Image Uploads" 3 | subtitle: "Handle Image Uploads" 4 | sort: 5 5 | --- 6 | 7 | PHP lets people upload files and with Intervention Image you can easily pass an uploaded image to the [make()](/v2/api/make) method. The standard way is to get the temp. file information from the ```$_FILES``` array. 8 | 9 | Read more about file uploads in the official [PHP documentation](http://www.php.net/manual/en/features.file-upload.php). 10 | 11 | #### Creating Image from File Upload 12 | 13 | ```php 14 | // read image from temporary file 15 | $img = Image::make($_FILES['image']['tmp_name']); 16 | 17 | // resize image 18 | $img->fit(300, 200); 19 | 20 | // save image 21 | $img->save('foo/bar.jpg'); 22 | ``` 23 | 24 | ## Handling image uploads in Laravel 25 | 26 | In a Laravel application it is also possible to pass an uploaded file directly to the make method. 27 | 28 | #### Creating Image from File Upload in Laravel 29 | 30 | ```php 31 | // resizing an uploaded file 32 | Image::make(Request::file('photo'))->resize(300, 200)->save('foo.jpg'); 33 | ``` 34 | -------------------------------------------------------------------------------- /image/v3/basics/meta-information.md: -------------------------------------------------------------------------------- 1 | --- 2 | label: "Meta Information" 3 | title: "Meta Information" 4 | subtitle: "Read Meta Data from Images" 5 | lead: "Discover how to manage meta information in images with Intervention Image. Learn to read image dimensions, resolution, and Exif data, including pixel sizes, DPI settings, and camera metadata." 6 | sort: 2 7 | --- 8 | 9 | [TOC] 10 | 11 | ## Image Sizes 12 | 13 | ### Read the Pixel Width 14 | 15 | > public Image::width(): integer 16 | 17 | Read the pixel width in pixels from an instance. 18 | 19 | #### Example 20 | 21 | ```php 22 | use Intervention\Image\ImageManager; 23 | use Intervention\Image\Drivers\Imagick\Driver; 24 | 25 | // create new manager instance with desired driver 26 | $manager = new ImageManager(new Driver()); 27 | 28 | // read an image 29 | $image = $manager->read('images/example.png'); 30 | 31 | // read the image width 32 | $width = $image->width(); 33 | ``` 34 | 35 | ### Read the Pixel Height 36 | 37 | > public Image::height(): integer 38 | 39 | Read the pixel height from an image instance. 40 | 41 | #### Example 42 | 43 | ```php 44 | use Intervention\Image\ImageManager; 45 | use Intervention\Image\Drivers\Gd\Driver; 46 | 47 | // create new manager instance with desired driver 48 | $manager = new ImageManager(new Driver()); 49 | 50 | // read an image 51 | $image = $manager->read('images/example.png'); 52 | 53 | // read the image height 54 | $height = $image->height(); 55 | ``` 56 | 57 | ### Read the Image Size as an Object 58 | 59 | > public Image::size(): SizeInterface 60 | 61 | Read the pixel size from an image instance. 62 | 63 | #### Example 64 | 65 | ```php 66 | use Intervention\Image\ImageManager; 67 | use Intervention\Image\Drivers\Imagick\Driver; 68 | 69 | // create new manager instance with desired driver 70 | $manager = new ImageManager(Driver::class); 71 | 72 | // read an image 73 | $image = $manager->read('images/example.png'); 74 | 75 | // read image size 76 | $size = $image->size(); 77 | 78 | // read aspect ratio 79 | $ratio = $size->aspectRatio(); 80 | 81 | // determine image format 82 | $is_portrait = $size->isPortrait(); // true 83 | $is_landscape = $size->isLandscape(); // false 84 | 85 | // read width from size 86 | $width = $size()->width(); 87 | ``` 88 | 89 | ## Image Resolution 90 | 91 | ### Read the Image Resolution 92 | 93 | > public Image::resolution(): ResolutionInterface 94 | 95 | Reads out the image resolution of the current instance in DPI. 96 | 97 | #### Example 98 | 99 | ```php 100 | use Intervention\Image\ImageManager; 101 | use Intervention\Image\Drivers\Gd\Driver; 102 | 103 | // create new manager instance with desired driver 104 | $manager = new ImageManager(Driver::class); 105 | 106 | // read an image 107 | $image = $manager->read('images/example.png'); 108 | 109 | // read image resolution object 110 | $resolution = $image->resolution(); 111 | 112 | // convert resolution to dpcm 113 | $resolution = $resolution->perCm(); 114 | 115 | // read resolution for each axis 116 | $x = $resolution->x(); 117 | $y = $resolution->y(); 118 | ``` 119 | 120 | ### Set the Image Resolution 121 | 122 | > public Image::setResolution(float $x, float $y): ImageInterface 123 | 124 | Set the image resolution in DPI for each axis. Please note that the resolution 125 | is encoded only for image formats that support this feature. 126 | 127 | #### Parameters 128 | 129 | | Name | Type | Description | 130 | | - | - | - | 131 | | x | float | Resolution on the x-axis | 132 | | y | float | Resolution on the y-axis | 133 | 134 | #### Example 135 | 136 | ```php 137 | use Intervention\Image\ImageManager; 138 | use Intervention\Image\Drivers\Gd\Driver; 139 | 140 | // create new manager instance with desired driver 141 | $manager = new ImageManager(new Driver()); 142 | 143 | // read an image 144 | $image = $manager->read('images/example.jpg'); 145 | 146 | // set image resolution to 300 DPI 147 | $image->setResolution(300, 300); 148 | ``` 149 | 150 | 151 | ## Exif Information 152 | 153 | Currently Intervention Image is only able to read Exif information. The 154 | possibility to write Exif data blocks is not implemented. 155 | 156 | ### Read Exif Information 157 | 158 | > public Image::exif(null|string $query = null): mixed 159 | 160 | This function reads Exif information from the current image instance. You have 161 | the option to pass a parameter to read a specific block of information from the 162 | Exif data directly. If no parameter is passed, all data will be returned. If 163 | the specified block is not found, `null` is returned as result. 164 | 165 | **To use this function, the PHP Exif extension must be installed.** 166 | 167 | #### Parameters 168 | 169 | | Name | Type | Description | 170 | | - | - | - | 171 | | query | string or null | Optionally query exif information block directly | 172 | 173 | #### Example 174 | 175 | ```php 176 | use Intervention\Image\ImageManager; 177 | use Intervention\Image\Drivers\Imagick\Driver; 178 | 179 | // create new manager instance with desired driver 180 | $manager = new ImageManager(new Driver()); 181 | 182 | // read an image 183 | $image = $manager->read('images/example.jpg'); 184 | 185 | // read the specific exif data 186 | $camera = $image->exif('IFD0.Model'); 187 | 188 | // read all exif information 189 | $all = $image->exif(); 190 | 191 | // the exif data block can be queried as well 192 | $camera = $all->get('IFD0.Model'); 193 | ``` 194 | -------------------------------------------------------------------------------- /image/v3/basics/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Basics" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /image/v3/getting-started/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installing Intervention Image" 4 | lead: "Learn how to install Intervention Image for PHP with Composer and discover what are requirements to run the library with your server environment seamlessly." 5 | sort: 1 6 | --- 7 | 8 | [TOC] 9 | 10 | ## Server Requirements 11 | 12 | Before you begin with the installation make sure that your server environment 13 | supports the following requirements. 14 | 15 | - PHP >= 8.1 16 | - Mbstring PHP Extension 17 | - Image Processing PHP Extension 18 | 19 | Although it is not a requirement, it is **highly recommended to have the Exif 20 | PHP extension installed** as well. This is used, among other things, to correctly 21 | display the orientation of images. 22 | 23 | ### Image Processing Extension 24 | 25 | Your server environment must have at least one PHP image processing extension 26 | installed. Intervention Image currently supports the three most popular. 27 | 28 | - [GD Image](https://www.php.net/manual/en/book.image.php) 29 | - [Imagick](https://www.php.net/manual/en/book.imagick.php) 30 | - [libvips](https://www.libvips.org) 31 | 32 | GD is part of most PHP installations. However I recommend using Imagick because 33 | I think it is faster and more efficient especially for larger images. Support 34 | for libvips is available via a driver that can be installed as an [add-on 35 | package](https://github.com/Intervention/image-driver-vips). 36 | 37 | Based on your environmen, the appropriate driver must be configured later. 38 | 39 | ## Installation 40 | 41 | Install Intervention Image with [Composer](https://getcomposer.org/) by running 42 | the following command. 43 | 44 | ```bash 45 | composer require intervention/image 46 | ``` 47 | 48 | This will install Intervention Image with the most recent version, your 49 | `composer.json` is automatically updated and you will be able use the package's 50 | classes via the autoloader. To do this you will need to require the just 51 | created `vendor/autoload.php` file to PSR-4 autoload all your installed 52 | composer packages. 53 | 54 | ```php 55 | require './vendor/autoload.php'; 56 | 57 | use Intervention\Image\ImageManager; 58 | use Intervention\Image\Drivers\Imagick\Driver; 59 | 60 | // create new manager instance with desired driver 61 | $manager = new ImageManager(new Driver()); 62 | ``` 63 | 64 | After installation you are ready to [configure the image manager](/v3/basics/configuration-drivers) and [read or create image instances](/v3/basics/instantiation). 65 | -------------------------------------------------------------------------------- /image/v3/getting-started/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Image" 3 | label: "Introduction" 4 | subtitle: "PHP Image Processing" 5 | lead: "Intervention Image is the most popular open source PHP image processing library. It provides an easy and expressive way to edit images and supports PHP's three most common image processing libraries GD Library, Imagick or libvips." 6 | sort: 0 7 | --- 8 | 9 | ### Features 10 | 11 | - Unified API for GD, Imagick or [libvips](https://github.com/Intervention/image-driver-vips) 12 | - Processing of animated Images 13 | - Support for colorspaces and profiles 14 | - Support for text wrapping and line height in the font system 15 | - Improved architecture 16 | - PSR-12 standardized 17 | 18 | The library is written to make PHP image manipulation easy and effortless. 19 | Whether you want to create image thumbnails, set watermarks, or format large 20 | image files, Intervention Image helps you accomplish any task with just a few 21 | lines of code. 22 | 23 | Version 3 improves on the solid features and adds unique new details. 24 | 25 | ### Code Example 26 | 27 | ```php 28 | use Intervention\Image\ImageManager; 29 | use Intervention\Image\Drivers\Gd\Driver; 30 | 31 | // create image manager with desired driver 32 | $manager = new ImageManager(new Driver()); 33 | 34 | // read image from file system 35 | $image = $manager->read('images/example.jpg'); 36 | 37 | // resize image proportionally to 300px width 38 | $image->scale(width: 300); 39 | 40 | // insert watermark 41 | $image->place('images/watermark.png'); 42 | 43 | // save modified image in new format 44 | $image->toPng()->save('images/foo.png'); 45 | 46 | ``` 47 | 48 | The library follows the FIG PSR-12 standard to ensure a high level of 49 | interoperability between shared PHP code and is fully unit tested. 50 | 51 | Read how to [install Intervention Image](/v3/getting-started/installation). 52 | -------------------------------------------------------------------------------- /image/v3/getting-started/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /image/v3/modifying-images/advanced.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Advanced" 3 | subtitle: "Advanced Image Modification" 4 | lead: "Discover the endless possibilities of Intervention Image by directly accessing the native image data and combining them with custom modifier classes." 5 | sort: 7 6 | --- 7 | 8 | If the supplied options are not sufficient, it is possible to create your own 9 | solutions using your own [custom modifiers](/v3/modifying-images/custom-modifiers). 10 | Furthermore, the native image object can be accessed, so that all functions 11 | used by the actual image processing libraries (such as GD or Imagick) can 12 | be used — even those not covered by Intervention Image. 13 | 14 | ## Access the Native Image Object 15 | 16 | Depending on the driver, each image object is mapped internally by either an 17 | instance of a `GDImage::class` or an `Imagick::class` object. The parent image object of 18 | Intervention Image provides access to this base object. 19 | 20 | The following example uses the native Imagick function 21 | [oilPaintImage()](https://www.php.net/manual/en/imagick.oilpaintimage.php), 22 | which is not included in this library. 23 | 24 | ```php 25 | use Intervention\Image\ImageManager; 26 | 27 | // read test image from a file 28 | $manager = ImageManager::imagick(); 29 | $image = $manager->read('test.png'); 30 | 31 | // access Imagick instance directly 32 | $imagick = $image->core()->native(); 33 | 34 | // use external Imagick function 35 | $imagick->oilPaintImage(4.5); 36 | ``` 37 | 38 | Combined with [custom modifiers](/v3/modifying-images/custom-modifiers), Intervention 39 | Image can be extended with your own modifier combinations for endless 40 | possibilities. 41 | -------------------------------------------------------------------------------- /image/v3/modifying-images/custom-modifiers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Custom Modifiers" 3 | subtitle: "Group Image Modifications in Classes" 4 | lead: "Streamline image transformations architecture with custom modifiers in Intervention Image. Learn to group and reuse complex modifications using custom classes that implement the ModifierInterface." 5 | sort: 6 6 | --- 7 | 8 | All modifier calls can be stored as a combination in a custom image modifier 9 | class. This modifier defines which commands should be applied to an image 10 | instance, in what order, and with what arguments. This makes it easy to 11 | combine complex transformations into a single reusable call. 12 | 13 | Intervention Image provides the simple `Intervention\Image\Interfaces\ModifierInterface`, which all modifiers need to implement. 14 | 15 | Once you have created your own modifier, you can apply them by using the `modify()` method. 16 | 17 | ## Custom Modifier Implementation 18 | 19 | The following very simple example shows a custom modifier class that combines a greyscale and a pixellation effect. 20 | 21 | ```php 22 | use Intervention\Image\Interfaces\ModifierInterface; 23 | use Intervention\Image\Interfaces\ImageInterface; 24 | 25 | class MyCustomModifier implements ModifierInterface 26 | { 27 | protected $size; 28 | 29 | public function __construct(int $size) 30 | { 31 | $this->size = $size; 32 | } 33 | 34 | public function apply(ImageInterface $image): ImageInterface 35 | { 36 | $image->pixelate($this->size); 37 | $image->greyscale(); 38 | 39 | return $image; 40 | } 41 | } 42 | ``` 43 | 44 | ## Apply Custom Modifiers 45 | 46 | Once the custom modifier is implemented, you can easily apply it to an image instance. 47 | 48 | > public Image::modify(ModifierInterface $modifier): ImageInterface 49 | 50 | #### Parameters 51 | 52 | | Name | Type | Description | 53 | | - | - | - | 54 | | modifier | Intervention\Image\Interfaces\ModifierInterface | Modifier object | 55 | 56 | #### Example 57 | 58 | ```php 59 | use Intervention\Image\ImageManager; 60 | 61 | // create new image instance 62 | $image = ImageManager::imagick()->read('images/example.jpg'); 63 | 64 | // apply modifier 65 | $image->modify(new MyCustomModifier(25)); 66 | ``` 67 | -------------------------------------------------------------------------------- /image/v3/modifying-images/inserting.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Insert Images" 3 | subtitle: "Place Images onto other Images" 4 | lead: "Learn how to insert images onto other images using the Intervention Image library. Position images, adjust offsets, and control opacity for custom overlays or watermarks." 5 | sort: 1 6 | --- 7 | 8 | [TOC] 9 | 10 | ## Insert Images 11 | 12 | > public Image::place(mixed $element, string $position = 'top-left', int $offset_x = 0, int $offset_y = 0, int $opacity = 100): ImageInterface 13 | 14 | Inserts an image at the specified position. The image to insert can be specified 15 | from any of the [supported image 16 | sources](/v3/basics/instantiation#reading-image-sources). Optionally you can 17 | pass coordinates for an offset to move the image relative to the specified 18 | position. It is also possible to control the opacity of the watermark using the 19 | `opacity` parameter. 20 | 21 | The possible `position` values are: 22 | 23 | - `top-left` (default) 24 | - `top` 25 | - `top-right` 26 | - `left` 27 | - `center` 28 | - `right` 29 | - `bottom-left` 30 | - `bottom` 31 | - `bottom-right` 32 | 33 | #### Parameters 34 | 35 | | Name | Type | Description | 36 | | - | - | - | 37 | | element | mixed | Source of the image to be placed | 38 | | position | string | Position of the image to be placed | 39 | | offset_x | int | Optional relative offset of the new image on x-axis | 40 | | offset_y | int | Optional relative offset of the new image on y-axis | 41 | | opacity | int | Control over the opacity of the placed image ranging from 0 (fully transparent) to 100 (opaque) | 42 | 43 | #### Example 44 | 45 | ```php 46 | use Intervention\Image\ImageManager; 47 | 48 | // create an test image from a file 49 | $manager = ImageManager::gd(); 50 | $image = $manager->read('test.png'); 51 | 52 | // paste another image 53 | $img->place('images/foo.png'); 54 | 55 | // create a new resized watermark instance and insert at bottom-right 56 | // corner with 10px offset and an opacity of 25% 57 | $img->place( 58 | 'images/watermark.png', 59 | 'bottom-right', 60 | 10, 61 | 10, 62 | 25 63 | ); 64 | ``` 65 | -------------------------------------------------------------------------------- /image/v3/modifying-images/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Modifying Images" 3 | sort: 2 4 | --- 5 | -------------------------------------------------------------------------------- /image/v3/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 3" 3 | status: "stable" 4 | --- 5 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # intervention.io Project Documentation 2 | 3 | Documentation in markdown for all projects on [intervention.io](https://intervention.io). 4 | 5 | ## Projects 6 | 7 | ### Intervention Image 8 | 9 | - [Documentation Source](/image) 10 | - [Website](https://image.intervention.io) 11 | 12 | ### Intervention Validation 13 | 14 | - [Documentation Source](/validation) 15 | - [Website](https://validation.intervention.io) 16 | 17 | ### Intervention Zodiac 18 | 19 | - [Documentation Source](/zodiac) 20 | - [Website](https://zodiac.intervention.io) 21 | 22 | ### Intervention HttpAuth 23 | 24 | - [Documentation Source](/httpauth) 25 | - [Website](https://httpauth.intervention.io) 26 | 27 | ## Authors 28 | 29 | This documentation is developed and maintained by [Oliver Vogel](https://intervention.io) 30 | 31 | Thanks to the community of [contributors](https://github.com/Intervention/docs/graphs/contributors) who have helped to improve this project. 32 | -------------------------------------------------------------------------------- /validation/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | sort: 1 3 | label: "Validation" 4 | title: "Intervention Validation" 5 | subtitle: "Missing Laravel Validation Rules" 6 | description: "Intervention Validation is an extension for Laravel's validation system with over 30 additional validation rules." 7 | package: "intervention/validation" 8 | repository_url: "https://github.com/Intervention/validation" 9 | license: "MIT" 10 | keywords: 11 | - php 12 | - validation 13 | - laravel 14 | --- 15 | -------------------------------------------------------------------------------- /validation/v3/introduction/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | sort: 1 5 | --- 6 | 7 | You can install this package quickly and easily with Composer. 8 | 9 | Require the package via Composer: 10 | 11 | ```bash 12 | composer require intervention/validation 13 | ``` 14 | 15 | The Validation library is built to work with the Laravel Framework (>=7). It comes with a service provider, which will be discovered automatically and registers the validation rules into your installation. 16 | -------------------------------------------------------------------------------- /validation/v3/introduction/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Validation" 3 | label: "Introduction" 4 | subtitle: "Missing Laravel Validation Rules" 5 | sort: 0 6 | --- 7 | 8 | Intervention Validation is an extension library for Laravel's own validation system. The package adds over 30 additional validation rules to verify data like IBAN, BIC, ISBN, creditcard numbers and more. 9 | 10 | - All rules implement the `Illuminate\Contracts\Validation\Rule` interface 11 | - Use the additional rules in combination with Laravel's own rules 12 | 13 | -------------------------------------------------------------------------------- /validation/v3/introduction/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v3/introduction/usage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage" 3 | subtitle: "Basic usage of Intervention Validation" 4 | sort: 2 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Usage with Laravel Framework 10 | 11 | The Validation library is built to work with the Laravel Framework and provides over 30 additional validation rules including error messages. You can use this rules in combination with Laravel's rules by passing them to the validator. 12 | 13 | ### Example 14 | 15 | ```php 16 | use Illuminate\Support\Facades\Validator; 17 | use Intervention\Validation\Rules\HexColor; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'color' => new Hexcolor(3), // pass rule as object 21 | 'number' => ['required', 'creditcard'], // or pass rule as string 22 | 'name' => 'required|min:3|max:20|username', // combining rules works as well 23 | ]); 24 | ``` 25 | 26 | ### Customizing Error Messages 27 | 28 | Add the corresponding key to `/resources/lang//validation.php` like this: 29 | 30 | ```php 31 | // example 32 | 'iban' => 'Please enter IBAN number!', 33 | ``` 34 | 35 | Or add your custom messages directly to the validator like described in the [Laravel docs](https://laravel.com/docs/8.x/validation#manual-customizing-the-error-messages). 36 | 37 | 38 | ## Standalone Usage 39 | 40 | It is also possible to use this library without the Laravel framework. You won't have the Laravel facades available, so make sure to use `Intervention\Validation\Validator` for your calls. 41 | 42 | ### Example 43 | 44 | ```php 45 | use Intervention\Validation\Validator; 46 | use Intervention\Validation\Rules\Creditcard; 47 | use Intervention\Validation\Exceptions\ValidationException; 48 | 49 | // use static factory method to create laravel validator 50 | $validator = Validator::make($request->all(), [ 51 | 'ccnumber' => new Creditcard(), 52 | 'iban' => ['required', 'iban'], 53 | 'color' => 'required|hexcolor:3', 54 | ]); 55 | 56 | // validate single values by calling static methods 57 | $result = Validator::isHexcolor('foobar'); // false 58 | $result = Validator::isHexcolor('#ccc'); // true 59 | $result = Validator::isBic('foo'); // false 60 | 61 | // assert single values 62 | try { 63 | Validator::assertHexcolor('foobar'); 64 | } catch (ValidationException $e) { 65 | $message = $e->getMessage(); 66 | } 67 | ``` 68 | -------------------------------------------------------------------------------- /validation/v3/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 3" 3 | status: "eol" 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v3/rules/base64.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Base64 Rule" 3 | subtitle: "Validate a Base64 Encoded String" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Base64::__construct() 7 | 8 | The field under validation must be [Base64 encoded](https://en.wikipedia.org/wiki/Base64). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Base64; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Base64(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/bic.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "BIC Rule" 3 | subtitle: "Validate a Business Identifier Code" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Bic::__construct() 7 | 8 | Checks if field under validation is a valid [Business Identifier Code](https://en.wikipedia.org/wiki/ISO_9362) (BIC). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Bic; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Bic(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/camelcase.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Camel Case Rule" 3 | subtitle: "Validate Camel Case String" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Camelcase::__construct() 7 | 8 | The field under validation must be a formated in [Camel case](https://en.wikipedia.org/wiki/Camel_case). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Camelcase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Camelcase(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/cidr.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "CIDR Rule" 3 | subtitle: "Validate Classless Inter-Domain Routing string" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Cidr::__construct() 7 | 8 | Check if the field under validation is a [Classless Inter-Domain Routing](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation (CIDR). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Cidr; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Cidr(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/creditcard.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Creditcard Rule" 3 | subtitle: "Validate Creditcard Numbers" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Creditcard::__construct() 7 | 8 | The field under validation must be a valid [creditcard number](https://en.wikipedia.org/wiki/Payment_card_number). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Creditcard; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Creditcard(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/data-uri-scheme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Data URI Rule" 3 | subtitle: "Validate Data URI Scheme String" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\DataUri::__construct() 7 | 8 | The field under validation must be a valid [Data URI](https://en.wikipedia.org/wiki/Data_URI_scheme). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\DataUri; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new DataUri(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/domain.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Domain Name Rule" 3 | subtitle: "Validate Domain Names" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Domainname::__construct() 7 | 8 | The field under validation must be a well formed [domainname](https://en.wikipedia.org/wiki/Domain_name). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Domainname; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Domainname(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/ean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "EAN Rule" 3 | subtitle: "Validate European Article Numbers" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Ean::__construct(?int $length = null) 7 | 8 | Checks for a valid [European Article Number](https://en.wikipedia.org/wiki/International_Article_Number). 9 | 10 | ### Parameters 11 | 12 | #### length (optional) 13 | 14 | Optional integer length (8 or 13) to check only for EAN-8 or EAN-13 or either one if not present. 15 | 16 | ### Example 17 | 18 | ```php 19 | use Intervention\Validation\Rules\Ean; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Ean(8), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v3/rules/gtin.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "GTIN Rule" 3 | subtitle: "Validate a Global Trade Item Number" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Gtin::__construct(?int $length = null) 7 | 8 | Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number). 9 | 10 | ### Parameters 11 | 12 | #### length (optional) 13 | 14 | Optional integer length to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14). 15 | 16 | ### Example 17 | 18 | ```php 19 | use Intervention\Validation\Rules\Gtin; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Gtin(14), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v3/rules/hex-color.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Hexadecimal Color Rule" 3 | subtitle: "Validate a Hexadecimal Color Code" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\HexColor::__construct(?int $length = null) 7 | 8 | The field under validation must be a valid [hexadecimal color code](https://en.wikipedia.org/wiki/Web_colors). 9 | 10 | ### Parameters 11 | 12 | #### length (optional) 13 | 14 | Optional length as integer to check only for shorthand (3 characters) or full hexadecimal (6 characters) form. 15 | 16 | ### Example 17 | 18 | ```php 19 | use Intervention\Validation\Rules\HexColor; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new HexColor(3), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v3/rules/html-clean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "HTML Clean Rule" 3 | subtitle: "Validate if Text is Free of any HTML Tags" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\HtmlClean::__construct() 7 | 8 | The field under validation must be free of any html code. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\HtmlClean; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new HtmlClean(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/iban.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "IBAN Rule" 3 | subtitle: "Validate International Bank Account Numbers" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Iban::__construct() 7 | 8 | Checks for a valid [International Bank Account Number](https://en.wikipedia.org/wiki/International_Bank_Account_Number) (IBAN). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Iban; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Iban(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/imei.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "IMEI Rule" 3 | subtitle: "Validate International Mobile Equipment Identity " 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Imei::__construct() 7 | 8 | The field under validation must be a [International Mobile Equipment Identity](https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity) (IMEI). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Imei; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Imei(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/isbn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISBN Rule" 3 | subtitle: "Validate International Standard Book Number" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Isbn::__construct(?int $length = null) 7 | 8 | The field under validation must be a valid [International Standard Book Number](https://en.wikipedia.org/wiki/International_Standard_Book_Number) (ISBN). 9 | 10 | ### Parameters 11 | 12 | #### length (optional) 13 | 14 | Optional length parameter as integer to check only for ISBN-10 or ISBN-13. 15 | 16 | ### Example 17 | 18 | ```php 19 | use Intervention\Validation\Rules\Isbn; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Isbn(10), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v3/rules/isin.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISIN Rule" 3 | subtitle: "Validate International Securities Identification Number" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Isin::__construct() 7 | 8 | Checks for a valid [International Securities Identification Number](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (ISIN). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Isin; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Isin(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/issn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISSN Rule" 3 | subtitle: "Validate International Standard Serial Number" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Issn::__construct() 7 | 8 | Checks for a valid [International Standard Serial Number](https://en.wikipedia.org/wiki/International_Standard_Serial_Number) (ISSN). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Issn; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Issn(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/jwt.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JWT Rule" 3 | subtitle: "Validate a JSON Web Token" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Jwt::__construct() 7 | 8 | The value under validation must be a in format of a [JSON Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Jwt; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Jwt(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/kebab-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Kebab Case Rule" 3 | subtitle: "Validate a String in Kebab Case" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Kebabcase::__construct() 7 | 8 | The value under validation must be formated in [Kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Kebabcase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Kebabcase(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/lower-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lower Case Rule" 3 | subtitle: "Validate a String in Lower Case" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Lowercase::__construct() 7 | 8 | The given value must be all lower case letters. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Lowercase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Lowercase(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/luhn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Luhn Rule" 3 | subtitle: "Validate a String Against Luhn Algorithm" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Luhn::__construct() 7 | 8 | The given value must verify against its included [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) check digit. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Luhn; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Luhn(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/mime-type.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Media (MIME) Type Rule" 3 | subtitle: "Validate MIME Type Strings" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\MimeType::__construct() 7 | 8 | Checks for a valid [Mime Type](https://en.wikipedia.org/wiki/Media_type) (Media type). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\MimeType; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new MimeType(), 21 | ]); 22 | ``` 23 | 24 | 25 | -------------------------------------------------------------------------------- /validation/v3/rules/postal-code.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Postal Code Rule" 3 | subtitle: "Validate Postal Codes for Individual Countries" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Postalcode::__construct(string $countrycode) 7 | 8 | The field under validation must be a [postal code](https://en.wikipedia.org/wiki/Postal_code) of the given country. 9 | 10 | ### Parameters 11 | 12 | #### countrycode 13 | 14 | Country code string in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. 15 | 16 | ### Example 17 | 18 | ```php 19 | use Intervention\Validation\Rules\Postalcode; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Postalcode('de'), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v3/rules/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Validation Rules" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v3/rules/semver.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Semantic Versioning Rule" 3 | subtitle: "Validate Semantic Version Numbers" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\SemVer::__construct() 7 | 8 | The field under validation must be a valid version numbers using [Semantic Versioning](https://semver.org/). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\SemVer; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new SemVer(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/slug.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Slug Rule" 3 | subtitle: "Validate a SEO-friendly Short Text" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Slug::__construct() 7 | 8 | The field under validation must be a user- and [SEO-friendly short text](https://en.wikipedia.org/wiki/Clean_URL#Slug). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Slug; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Slug(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/snake-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Snake Case Rule" 3 | subtitle: "Validate String Formated in Snake Case" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Snakecase::__construct() 7 | 8 | The field under validation must formated as [Snake case](https://en.wikipedia.org/wiki/Snake_case) text. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Snakecase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Snakecase(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/title-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Title Case Rule" 3 | subtitle: "Validate String Formated in Title Case" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Titlecase::__construct() 7 | 8 | The field under validation must formated in [Title case](https://en.wikipedia.org/wiki/Title_case). 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Titlecase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Titlecase(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/ulid.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ULID Rule" 3 | subtitle: "Validate a Universally Unique Lexicographically Sortable Identifier" 4 | sort: 0 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Ulid::__construct() 8 | 9 | The field under validation must be a valid [Universally Unique Lexicographically Sortable Identifier](https://github.com/ulid/spec). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Intervention\Validation\Rules\Ulid; 19 | 20 | $validator = Validator::make($request->all(), [ 21 | 'attribute-key' => new Ulid(), 22 | ]); 23 | ``` 24 | -------------------------------------------------------------------------------- /validation/v3/rules/upper-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Upper Case Rule" 3 | subtitle: "Validate String Formated in Upper Case" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Uppercase::__construct() 7 | 8 | The field under validation must be all upper case. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Uppercase; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Uppercase(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v3/rules/username.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Username Rule" 3 | subtitle: "Validate a Typical Username" 4 | --- 5 | 6 | > public Intervention\Validation\Rules\Username::__construct() 7 | 8 | The field under validation must be a valid username. Consisting of alpha-numeric characters, underscores, minus and starting with a alphabetic character. Multiple underscore and minus chars are not allowed. Underscore and minus chars are not allowed at the beginning or end. 9 | 10 | ### Parameters 11 | 12 | none 13 | 14 | ### Example 15 | 16 | ```php 17 | use Intervention\Validation\Rules\Username; 18 | 19 | $validator = Validator::make($request->all(), [ 20 | 'attribute-key' => new Username(), 21 | ]); 22 | ``` 23 | -------------------------------------------------------------------------------- /validation/v4/introduction/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Validation" 3 | label: "Introduction" 4 | subtitle: "Missing Laravel Validation Rules" 5 | lead: "Enhance Laravel's validation system seamlessly with Intervention Validation, offering 30+ additional validation rules like IBAN, ISBN, postal codes, credit card checks and more." 6 | sort: 0 7 | --- 8 | 9 | - Over 30 additional validations rules for Laravel's validator 10 | - Including error messages in 11 different languages 11 | - All rules implement the `Illuminate\Contracts\Validation\ValidationRule` interface 12 | - Use the additional rules in combination with Laravel's own rules 13 | 14 | ### Installation 15 | 16 | You can install this package quickly and easily with Composer. 17 | 18 | ```bash 19 | composer require intervention/validation 20 | ``` 21 | 22 | The Validation library is built to work with the Laravel Framework (>=10). It 23 | comes with a service provider, which will be discovered automatically and 24 | registers the validation rules into your installation. 25 | 26 | ### Use with Laravel Framework 27 | 28 | Intervention Validation is built to work with [Laravel's 29 | Validation Framework](https://laravel.com/docs/validation) and provides over 30 30 | additional validation rules including error messages in 11 different languages. 31 | 32 | You can use these rules in combination with Laravel's own rules by passing them to the validator. 33 | 34 | #### Example with Controller 35 | 36 | ```php 37 | use Intervention\Validation\Rules\Hexadecimalcolor; 38 | 39 | public function store(Request $request): RedirectResponse 40 | { 41 | $validated = $request->validate([ 42 | 'color' => new Hexadecimalcolor(3), // pass rule as object 43 | 'number' => ['required', 'creditcard'], // or pass rule as string 44 | 'name' => 'required|min:3|max:20|username', // combining rules works as well 45 | ]); 46 | 47 | // The data is valid... 48 | } 49 | ``` 50 | 51 | #### Example with Form Request Validation 52 | 53 | ```php 54 | use Intervention\Validation\Rules\Hexadecimalcolor; 55 | 56 | public function rules(): array 57 | { 58 | return [ 59 | 'color' => new Hexadecimalcolor(3), // pass rule as object 60 | 'number' => ['required', 'creditcard'], // or pass rule as string 61 | 'name' => 'required|min:3|max:20|username', // combining rules works as well 62 | ]; 63 | } 64 | ``` 65 | 66 | #### Example with Manually Created Validator 67 | 68 | ```php 69 | use Illuminate\Support\Facades\Validator; 70 | use Intervention\Validation\Rules\Hexadecimalcolor; 71 | 72 | $validator = Validator::make($request->all(), [ 73 | 'color' => new Hexadecimalcolor(3), // pass rule as object 74 | 'number' => ['required', 'creditcard'], // or pass rule as string 75 | 'name' => 'required|min:3|max:20|username', // combining rules works as well 76 | ]); 77 | ``` 78 | 79 | ### Customizing Error Messages 80 | 81 | Add the corresponding key to `/resources/lang//validation.php` like this: 82 | 83 | ```php 84 | 'iban' => 'Please enter IBAN number!', 85 | ``` 86 | 87 | Or add your custom messages directly to the validator like [described in the 88 | Laravel docs](https://laravel.com/docs/validation#customizing-the-error-messages). 89 | -------------------------------------------------------------------------------- /validation/v4/introduction/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v4/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 4" 3 | status: "stable" 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v4/rules/austrian-insurance-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Austrian Insurance Number Rule" 3 | subtitle: "Validate the Austria Social Insurance Number" 4 | lead: "Explore how to validate the Austrian Social Insurance Number with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\AustrianInsuranceNumber::__construct() 8 | 9 | Checks for a valid [austrian social insurance number](https://de.wikipedia.org/wiki/Sozialversicherungsnummer#%C3%96sterreich). 10 | 11 | ### Example 12 | 13 | ```php 14 | use Illuminate\Support\Facades\Validator; 15 | use Intervention\Validation\Rules\AustrianInsuranceNumber; 16 | 17 | // validate GTIN 18 | $validator = Validator::make($request->all(), [ 19 | 'attribute-key' => new AustrianInsuranceNumber(), 20 | ]); 21 | ``` 22 | -------------------------------------------------------------------------------- /validation/v4/rules/base64.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Base64 Rule" 3 | subtitle: "Validate a Base64 Encoded String" 4 | lead: "Discover how to validate Base64 encoded strings with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Base64::__construct() 8 | 9 | The field under validation must be [Base64 encoded](https://en.wikipedia.org/wiki/Base64). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Base64; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Base64(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/bic.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "BIC Rule" 3 | subtitle: "Validate a Business Identifier Code" 4 | lead: "Learn how to validate Business Identifier codes with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Bic::__construct() 8 | 9 | Checks if field under validation is a valid [Business Identifier Code](https://en.wikipedia.org/wiki/ISO_9362) (BIC). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Bic; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Bic(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/camelcase.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Camel Case Rule" 3 | subtitle: "Validate Camel Case String" 4 | lead: "Explore how to validate camel case strings with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Camelcase::__construct() 8 | 9 | The field under validation must be a formated in [Camel case](https://en.wikipedia.org/wiki/Camel_case). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Camelcase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Camelcase(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/cidr.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "CIDR Rule" 3 | subtitle: "Validate Classless Inter-Domain Routing string" 4 | lead: "Discover how to validate Classless Inter-Domain Routing notations (CIDR) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Cidr::__construct() 8 | 9 | Check if the field under validation is a [Classless Inter-Domain Routing](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation (CIDR). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Cidr; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Cidr(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/creditcard.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Creditcard Rule" 3 | subtitle: "Validate Creditcard Numbers" 4 | lead: "Learn how to validate the creditcard numbers with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Creditcard::__construct() 8 | 9 | The field under validation must be a valid [creditcard number](https://en.wikipedia.org/wiki/Payment_card_number). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Creditcard; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Creditcard(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/data-uri-scheme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Data URI Rule" 3 | subtitle: "Validate Data URI scheme string" 4 | lead: "Explore how to validate Data URI scheme strings with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\DataUri::__construct(?array $media_types = null) 8 | 9 | The field under validation must be a valid [Data URI](https://en.wikipedia.org/wiki/Data_URI_scheme). 10 | 11 | ### Parameters 12 | 13 | #### media_types (optional) 14 | 15 | Parameter to determine the media type to be validated. Can either be `null` to 16 | allow all valid media types or an array of allowed types. 17 | 18 | ### Example 19 | 20 | ```php 21 | use Illuminate\Support\Facades\Validator; 22 | use Intervention\Validation\Rules\DataUri; 23 | 24 | $validator = Validator::make($request->all(), [ 25 | 'attribute-key' => new DataUri(), 26 | ]); 27 | ``` 28 | 29 | ```php 30 | use Illuminate\Support\Facades\Validator; 31 | use Intervention\Validation\Rules\DataUri; 32 | 33 | $validator = Validator::make($request->all(), [ 34 | 'attribute-key' => new DataUri([ 35 | 'image/jpeg', 36 | 'image/png', 37 | ]), 38 | ]); 39 | ``` 40 | -------------------------------------------------------------------------------- /validation/v4/rules/domain.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Domain Name Rule" 3 | subtitle: "Validate Domain Names" 4 | lead: "Learn how to validate the domain names with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Domainname::__construct() 8 | 9 | The field under validation must be a well formed [domainname](https://en.wikipedia.org/wiki/Domain_name). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Domainname; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Domainname(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/ean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "EAN Rule" 3 | subtitle: "Validate European Article Numbers" 4 | lead: "Explore how to validate European Article Numbers with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Ean::__construct(array $lengths = [8, 13]) 8 | 9 | Checks for a valid [European Article Number](https://en.wikipedia.org/wiki/International_Article_Number). 10 | 11 | ### Parameters 12 | 13 | #### lengths (optional) 14 | 15 | Optional array of allowed lengths (8 or 13) to check only for EAN-8 or EAN-13 or both. 16 | 17 | ### Example 18 | 19 | ```php 20 | use Illuminate\Support\Facades\Validator; 21 | use Intervention\Validation\Rules\Ean; 22 | 23 | $validator = Validator::make($request->all(), [ 24 | 'attribute-key' => new Ean(), 25 | ]); 26 | ``` 27 | 28 | ```php 29 | use Illuminate\Support\Facades\Validator; 30 | use Intervention\Validation\Rules\Ean; 31 | 32 | $validator = Validator::make($request->all(), [ 33 | 'attribute-key' => new Ean([8]), 34 | ]); 35 | ``` 36 | -------------------------------------------------------------------------------- /validation/v4/rules/grid.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "GRid Rule" 3 | subtitle: "Validate Global Release Identifier (GRid)" 4 | lead: "Learn how to validate the Global Release Identifier (GRid) format with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Grid::__construct() 8 | 9 | Checks for a valid [Global Release Identifier](https://en.wikipedia.org/wiki/Global_Release_Identifier) (GRid). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Grid; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Grid(), 23 | ]); 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /validation/v4/rules/gtin.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "GTIN Rule" 3 | subtitle: "Validate a Global Trade Item Number" 4 | lead: "Learn how to validate the Global Trait Item Numbers (GTIN) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Gtin::__construct(array $lengths = [8, 12, 13, 14]) 8 | 9 | Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number). 10 | 11 | ### Parameters 12 | 13 | #### lengths (optional) 14 | 15 | Optional array of allowed lengths to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14). 16 | 17 | ### Example 18 | 19 | ```php 20 | use Illuminate\Support\Facades\Validator; 21 | use Intervention\Validation\Rules\Gtin; 22 | 23 | // validate GTIN 24 | $validator = Validator::make($request->all(), [ 25 | 'attribute-key' => new Gtin(), 26 | ]); 27 | ``` 28 | 29 | ```php 30 | use Illuminate\Support\Facades\Validator; 31 | use Intervention\Validation\Rules\Gtin; 32 | 33 | // validate GTIN-8 or GTIN-12 34 | $validator = Validator::make($request->all(), [ 35 | 'attribute-key' => new Gtin([8, 12]), 36 | ]); 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /validation/v4/rules/hex-color.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Hexadecimal Color Rule" 3 | subtitle: "Validate a Hexadecimal Color Code" 4 | lead: "Explore how to validate hexadecimal color codes also known as web colors with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\HexColor::__construct(array $lengths = [3, 4, 6, 8]) 8 | 9 | The field under validation must be a valid [hexadecimal color code](https://en.wikipedia.org/wiki/Web_colors). 10 | 11 | ### Parameters 12 | 13 | #### lengths (optional) 14 | 15 | Pass optionally allowed lengths as an array to check only for shorthand (3 or 4 characters) or full hexadecimal (6 or 8 characters) form or combinations. 16 | 17 | ### Example 18 | 19 | ```php 20 | use Illuminate\Support\Facades\Validator; 21 | use Intervention\Validation\Rules\HexColor; 22 | 23 | $validator = Validator::make($request->all(), [ 24 | 'attribute-key' => new HexColor([3, 6]), 25 | ]); 26 | ``` 27 | -------------------------------------------------------------------------------- /validation/v4/rules/html-clean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "HTML Clean Rule" 3 | subtitle: "Validate if Text is Free of any HTML Tags" 4 | lead: "Learn how to validate that strings are free of any HTML code with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\HtmlClean::__construct() 8 | 9 | The field under validation must be free of any html code. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\HtmlClean; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new HtmlClean(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/iban.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "IBAN Rule" 3 | subtitle: "Validate International Bank Account Numbers" 4 | lead: "Explore how to validate International Bank Account Numbers (IBAN) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Iban::__construct() 8 | 9 | Checks for a valid [International Bank Account Number](https://en.wikipedia.org/wiki/International_Bank_Account_Number) (IBAN). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Iban; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Iban(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/imei.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "IMEI Rule" 3 | subtitle: "Validate International Mobile Equipment Identity " 4 | lead: "Learn how to validate the International Mobile Equipment Identifier format (IMEI) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Imei::__construct() 8 | 9 | The field under validation must be a [International Mobile Equipment Identity](https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity) (IMEI). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Imei; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Imei(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/isbn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISBN Rule" 3 | subtitle: "Validate International Standard Book Number" 4 | lead: "Learn how to validate International Static Book Numbers (ISBN) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Isbn::__construct(array $lengths = [10, 13]) 8 | 9 | The field under validation must be a valid [International Standard Book Number](https://en.wikipedia.org/wiki/International_Standard_Book_Number) (ISBN). 10 | 11 | ### Parameters 12 | 13 | #### lengths (optional) 14 | 15 | Optional array of allowed lengths to check only for ISBN-10 or ISBN-13. 16 | 17 | ### Example 18 | 19 | ```php 20 | use Illuminate\Support\Facades\Validator; 21 | use Intervention\Validation\Rules\Isbn; 22 | 23 | $validator = Validator::make($request->all(), [ 24 | 'attribute-key' => new Isbn(), 25 | ]); 26 | ``` 27 | 28 | ```php 29 | use Illuminate\Support\Facades\Validator; 30 | use Intervention\Validation\Rules\Isbn; 31 | 32 | $validator = Validator::make($request->all(), [ 33 | 'attribute-key' => new Isbn([13]), 34 | ]); 35 | ``` 36 | -------------------------------------------------------------------------------- /validation/v4/rules/isin.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISIN Rule" 3 | subtitle: "Validate International Securities Identification Number" 4 | lead: "Discover how to validate International Securities Identification Numbers (ISIN) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Isin::__construct() 8 | 9 | Checks for a valid [International Securities Identification Number](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (ISIN). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Isin; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Isin(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/isrc.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISRC Rule" 3 | subtitle: "Validate International Standard Recording Codes" 4 | lead: "Explore how to validate International Standard Recording Codes with the validation rules of Intervention Validation for your Laravel app." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Isrc::__construct() 8 | 9 | Checks for a valid [International Standard Recording Code](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). 10 | 11 | ### Example 12 | 13 | ```php 14 | use Illuminate\Support\Facades\Validator; 15 | use Intervention\Validation\Rules\Isrc; 16 | 17 | // validate code 18 | $validator = Validator::make($request->all(), [ 19 | 'attribute-key' => new Isrc(), 20 | ]); 21 | ``` 22 | -------------------------------------------------------------------------------- /validation/v4/rules/issn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ISSN Rule" 3 | subtitle: "Validate International Standard Serial Number" 4 | lead: "Explore how to validate International Standard Serial Numbers (ISSN) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Issn::__construct() 8 | 9 | Checks for a valid [International Standard Serial Number](https://en.wikipedia.org/wiki/International_Standard_Serial_Number) (ISSN). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Issn; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Issn(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/jwt.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "JWT Rule" 3 | subtitle: "Validate a JSON Web Token" 4 | lead: "Learn how to validate the JSON Web Token format with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Jwt::__construct() 8 | 9 | The value under validation must be a in format of a [JSON Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Jwt; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Jwt(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/kebab-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Kebab Case Rule" 3 | subtitle: "Validate a String in Kebab Case" 4 | lead: "Discover how to validate strings in Kebab Case with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Kebabcase::__construct() 8 | 9 | The value under validation must be formated in [Kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Kebabcase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Kebabcase(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/lower-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Lower Case Rule" 3 | subtitle: "Validate a String in Lower Case" 4 | lead: "Discover how to validate lower case strings with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Lowercase::__construct() 8 | 9 | The given value must be all lower case letters. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Lowercase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Lowercase(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/luhn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Luhn Rule" 3 | subtitle: "Validate a String Against Luhn Algorithm" 4 | lead: "Learn how to validate strings agains the Luhn Algorithm with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Luhn::__construct() 8 | 9 | The given value must verify against its included [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) check digit. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Luhn; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Luhn(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/mime-type.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Media (MIME) Type Rule" 3 | subtitle: "Validate MIME Type Strings" 4 | lead: "Explore how to validate mime type strings with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\MimeType::__construct() 8 | 9 | Checks for a valid [Mime Type](https://en.wikipedia.org/wiki/Media_type) (Media type). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\MimeType; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new MimeType(), 23 | ]); 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /validation/v4/rules/postal-code.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Postal Code Rule" 3 | subtitle: "Validate Postal Codes for Individual Countries" 4 | lead: "Explore how to validate international postal codes with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Postalcode::__construct(array $countrycodes = []) 8 | 9 | The field under validation must be a [postal code](https://en.wikipedia.org/wiki/Postal_code) of the given country. 10 | 11 | ### Parameters 12 | 13 | #### countrycodes 14 | 15 | Array of allowed country code strings in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. 16 | 17 | ### Example 18 | 19 | ```php 20 | use Illuminate\Support\Facades\Validator; 21 | use Intervention\Validation\Rules\Postalcode; 22 | 23 | $validator = Validator::make($request->all(), [ 24 | 'attribute-key' => new Postalcode(['de', 'nl']), 25 | ]); 26 | ``` 27 | 28 | ### Validate by Reference 29 | 30 | > public Intervention\Validation\Rules\Postalcode::reference(string $reference) 31 | 32 | The field under validation must be a [postal code](https://en.wikipedia.org/wiki/Postal_code) 33 | of the given country. The value to be validated is obtained from the sent data via a reference. 34 | This can be useful if, for example, you select a country elsewhere and this selection is used 35 | to determine how the zip code is validated. 36 | 37 | ### Parameters 38 | 39 | #### reference 40 | 41 | The key where the country code is stored in the validation data. 42 | 43 | ### Example 44 | 45 | ```php 46 | use Illuminate\Support\Facades\Validator; 47 | use Intervention\Validation\Rules\Postalcode; 48 | 49 | $validator = Validator::make($request->all(), [ 50 | 'attribute-key' => Postalcode::reference('country'), 51 | ]); 52 | ``` 53 | -------------------------------------------------------------------------------- /validation/v4/rules/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Validation Rules" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /validation/v4/rules/semver.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Semantic Versioning Rule" 3 | subtitle: "Validate Semantic Version Numbers" 4 | lead: "Learn how to validate Semantic Version Numbers (semver) with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\SemVer::__construct() 8 | 9 | The field under validation must be a valid version numbers using [Semantic Versioning](https://semver.org/). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\SemVer; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new SemVer(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/slug.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Slug Rule" 3 | subtitle: "Validate a SEO-friendly Short Text" 4 | lead: "Explore how to validate SEO-friendly short texts with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Slug::__construct() 8 | 9 | The field under validation must be a user- and [SEO-friendly short text](https://en.wikipedia.org/wiki/Clean_URL#Slug). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Slug; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Slug(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/snake-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Snake Case Rule" 3 | subtitle: "Validate String Formated in Snake Case" 4 | lead: "Discover how to validate strings formated in snake case with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Snakecase::__construct() 8 | 9 | The field under validation must formated as [Snake case](https://en.wikipedia.org/wiki/Snake_case) text. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Snakecase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Snakecase(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/title-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Title Case Rule" 3 | subtitle: "Validate String Formated in Title Case" 4 | lead: "Explore how to validate strings formated in title case with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Titlecase::__construct() 8 | 9 | The field under validation must formated in [Title case](https://en.wikipedia.org/wiki/Title_case). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Titlecase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Titlecase(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/ulid.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ULID Rule" 3 | subtitle: "Validate a Universally Unique Lexicographically Sortable Identifier" 4 | lead: "Learn how to validate the Universally Unique Lexicographically Sortable Identifier (ULID) format with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Ulid::__construct() 8 | 9 | The field under validation must be a valid [Universally Unique Lexicographically Sortable Identifier](https://github.com/ulid/spec). 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Ulid; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Ulid(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/upper-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Upper Case Rule" 3 | subtitle: "Validate String Formated in Upper Case" 4 | lead: "Discover how to validate strings in upper case format with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Uppercase::__construct() 8 | 9 | The field under validation must be all upper case. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Uppercase; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Uppercase(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /validation/v4/rules/username.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Username Rule" 3 | subtitle: "Validate a Typical Username" 4 | lead: "Explore how to validate typical usernames with the additional validation rules of Intervention Validation for your Laravel application." 5 | --- 6 | 7 | > public Intervention\Validation\Rules\Username::__construct() 8 | 9 | The field under validation must be a valid username. Consisting of alpha-numeric characters, underscores, minus and starting with a alphabetic character. Multiple underscore and minus chars are not allowed. Underscore and minus chars are not allowed at the beginning or end. 10 | 11 | ### Parameters 12 | 13 | none 14 | 15 | ### Example 16 | 17 | ```php 18 | use Illuminate\Support\Facades\Validator; 19 | use Intervention\Validation\Rules\Username; 20 | 21 | $validator = Validator::make($request->all(), [ 22 | 'attribute-key' => new Username(), 23 | ]); 24 | ``` 25 | -------------------------------------------------------------------------------- /zodiac/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | sort: 2 3 | label: "Zodiac" 4 | title: "Intervention Zodiac" 5 | subtitle: "PHP Zodiac Sign Calculator" 6 | description: "Intervention Zodiac is star sign calculator that resolves the zodiac sign from various data types." 7 | package: "intervention/zodiac" 8 | repository_url: "https://github.com/Intervention/zodiac" 9 | license: "MIT" 10 | keywords: 11 | - php 12 | - "zodiac sign" 13 | - "astrological sign" 14 | - "star sign" 15 | - calculator 16 | --- 17 | -------------------------------------------------------------------------------- /zodiac/v3/api/calculator.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Calculator" 3 | subtitle: "Using the Zodiac Calculator Class" 4 | sort: 0 5 | --- 6 | 7 | [TOC] 8 | 9 | The calculator class works a a starting point to transform different types of dates into zodiac objects. 10 | 11 | ### Instantiate from Scalar Dates 12 | 13 | The calculator class can read dates from **integer types** (unix timestamp) as well as **text strings**, which can represent a relative time (last monday, tomorrow, last day of next month) or an absolute time (first day of June 1983, 2011-11-11). 14 | 15 | ```php 16 | use Intervention\Zodiac\Calculator; 17 | 18 | // create from iso date 19 | $zodiac = Calculator::make('1992-03-19'); 20 | 21 | // create from relative date 22 | $zodiac = (string) Calculator::make('first day of June 2008'); 23 | 24 | // create from unix timestamp integer 25 | $zodiac = (string) Calculator::make(1641719287); 26 | ``` 27 | 28 | ### Instantiate from Date Objects 29 | 30 | You can also pass date objects (`DateTime` or `Carbon`) to instantiate new zodiac objects. 31 | 32 | ```php 33 | use Intervention\Zodiac\Calculator; 34 | 35 | // create from datetime objects 36 | $zodiac = Calculator::make(new DateTime('1977-03-15')); 37 | 38 | // create from carbon objects 39 | $zodiac = Calculator::make(Carbon::yesterday()); 40 | ``` 41 | 42 | Continue reading to learn what you can do with the [zodiac objects](/v3/api/zodiac). 43 | -------------------------------------------------------------------------------- /zodiac/v3/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v3/api/zodiac.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Zodiac" 3 | subtitle: "Working with Zodiac Objects" 4 | sort: 1 5 | --- 6 | 7 | [TOC] 8 | 9 | The zodiac objects returned from the [calculator](/v3/api/calculator) can be used in the following ways. 10 | 11 | ### Zodiac Name 12 | 13 | > public Zodiac::name(): string 14 | 15 | Return the name of the current zodiac. This is more a identification key than a textual title. It's possible to cast the zodiac object to a string type to get the same result. 16 | 17 | ```php 18 | use Intervention\Zodiac\Calculator; 19 | 20 | // create from iso date 21 | $zodiac = Calculator::make('1977-06-17'); 22 | $name = $zodiac->name(); // gemini 23 | $name = (string) $zodiac; // get name by casting to string 24 | ``` 25 | 26 | ### Localized Title 27 | 28 | > public Zodiac::localized(?string $locale = null): string 29 | 30 | Return the localized title of the current zodiac in the given locale. The locale parameter is optional, by default the english language is returned. 31 | 32 | ```php 33 | use Intervention\Zodiac\Calculator; 34 | 35 | // create from iso date 36 | $zodiac = Calculator::make('1977-06-17'); 37 | $name = $zodiac->localized('fr'); // Gémeaux 38 | ``` 39 | 40 | ### HTML Representation 41 | 42 | > public Zodiac::html(): string 43 | 44 | Returns the [HTML UTF-8 symbol code](https://www.w3schools.com/charsets/ref_utf_symbols.asp) representing an icon of the current zodiac sign. 45 | 46 | ```php 47 | use Intervention\Zodiac\Calculator; 48 | 49 | // create from iso date 50 | $zodiac = Calculator::make('1977-06-17'); 51 | $name = $zodiac->html(); // ♊ 52 | ``` 53 | -------------------------------------------------------------------------------- /zodiac/v3/introduction/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | sort: 1 5 | --- 6 | 7 | You can install this package quickly and easily with Composer. 8 | 9 | Require the package via Composer: 10 | 11 | ```bash 12 | composer require intervention/zodiac 13 | ``` 14 | 15 | Although the library is **framework agnostic** it comes with a service provider for the [Laravel Framework](https://www.laravel.com/). Which will be discovered automatically and registers the calculator into your installation. 16 | 17 | After the installation you can start [using the calculator](/v3/api/calculator). 18 | -------------------------------------------------------------------------------- /zodiac/v3/introduction/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Zodiac" 3 | label: "Introduction" 4 | subtitle: "PHP Zodiac Sign Calculator" 5 | sort: 0 6 | --- 7 | 8 | Intervention Zodiac is a calculator for zodiac signs to resolve the respective zodiac sign from various data types. 9 | 10 | ### Code Example 11 | 12 | ```php 13 | use Intervention\Zodiac\Calculator; 14 | use DateTime; 15 | use Carbon\Carbon; 16 | 17 | // get zodiac object from a date 18 | $zodiac = Calculator::make('1980-09-15'); // virgo 19 | 20 | // method takes mixed formats 21 | $zodiac = Calculator::make('first day of June 2008'); // gemini 22 | 23 | // even DateTime objects 24 | $zodiac = Calculator::make(new DateTime('1977-03-15')); // pisces 25 | 26 | // get zodiac from a Carbon 27 | $zodiac = Calculator::make(Carbon::yesterday()); 28 | ``` 29 | 30 | Read how to [install the package](/v3/introduction/installation). 31 | -------------------------------------------------------------------------------- /zodiac/v3/introduction/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v3/introduction/usage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage" 3 | subtitle: "How to Use Intervention Zodiac" 4 | sort: 2 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Basic Usage 10 | 11 | Use the [calculator](/v3/api/calculator) class to calculate [zodiac signs](/v3/api/zodiac) from various date types. The method `make` reads different date types. Reed the documentation on the [calculator class](/v3/api/calculator) for more information. 12 | 13 | ### Example 14 | 15 | ```php 16 | use Intervention\Zodiac\Calculator; 17 | use Intervention\Zodiac\Zodiacs\Scorpio; 18 | 19 | $calculator = new Calculator(); 20 | $sign = $calculator->make('2000-10-27'); 21 | 22 | if ($zodiac instanceof Scorpio) { 23 | // my zodiac sign is scorpio ... 24 | } 25 | ``` 26 | 27 | ### Static Example 28 | 29 | It's also possible to start the calculation with a static call. See the following example. 30 | 31 | ```php 32 | use Intervention\Zodiac\Calculator; 33 | use Intervention\Zodiac\Zodiacs\Scorpio; 34 | 35 | $sign = Calculator::make('2000-10-27'); 36 | ``` 37 | 38 | ## Usage with Laravel Framework 39 | 40 | The package comes with an integrated bridge to the Laravel Framework and includes a service provider and facade. After the installation Laravel will automatically register the service provider. 41 | 42 | ### Example 43 | 44 | In Laravel, the `make()` method is also used. However, the base class is different since we are now working with the facade. The service providers injects the framework's translator automatically. See the following example on how to calculate a zodiac sign from a get parameter and you can start right away. 45 | 46 | ```php 47 | use Illuminate\Support\Facades\Route; 48 | use Illuminate\Http\Request; 49 | 50 | Route::get('/', function (Request $request) { 51 | $sign = Zodiac::make($request->input('birthday')); 52 | return $sign->localized(); 53 | }); 54 | ``` 55 | 56 | In Laravel the `localized()` method returns by default in the currently configured locale. 57 | 58 | ### Eloquent Model Trait 59 | 60 | By including `Intervention\Zodiac\Laravel\Traits\CanResolveZodiac` your Eloquent Model gets a new zodiac attribute, which is created based on the birthday attribute of the current model and returns a zodiac object. 61 | 62 | #### Include Trait 63 | 64 | ```php 65 | class User extends Model 66 | { 67 | // include trait 68 | use \Intervention\Zodiac\Laravel\Traits\CanResolveZodiac; 69 | 70 | // optional: If you want overwrite attribute. By default `birthday` 71 | protected $birthdayAttribute = 'date_of_birth'; 72 | } 73 | ``` 74 | 75 | #### Zodiac Attribute 76 | 77 | ```php 78 | // retrieve zodiac attribute 79 | $user = App\User::create(['birthday' => '1980-03-15']); 80 | $zodiac = $user->zodiac; // Intervention\Zodiac\Zodiacs\Pisces 81 | ``` 82 | -------------------------------------------------------------------------------- /zodiac/v3/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 3" 3 | status: "eol" 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v4/api/calculator.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Calculator" 3 | subtitle: "Using the Zodiac Calculator Class" 4 | sort: 0 5 | --- 6 | 7 | [TOC] 8 | 9 | The calculator class works a a starting point to transform different types of dates into zodiac objects. 10 | 11 | ### Instantiate from Scalar Dates 12 | 13 | The calculator class can read dates from **integer types** (unix timestamp) as well as **text strings**, which can represent a relative time (last monday, tomorrow, last day of next month) or an absolute time (first day of June 1983, 2011-11-11). 14 | 15 | ```php 16 | use Intervention\Zodiac\Calculator; 17 | 18 | // create from iso date 19 | $zodiac = Calculator::make('1992-03-19'); 20 | 21 | // create from relative date 22 | $zodiac = (string) Calculator::make('first day of June 2008'); 23 | 24 | // create from unix timestamp integer 25 | $zodiac = (string) Calculator::make(1641719287); 26 | ``` 27 | 28 | ### Instantiate from Date Objects 29 | 30 | You can also pass date objects (`DateTime` or `Carbon`) to instantiate new zodiac objects. 31 | 32 | ```php 33 | use Intervention\Zodiac\Calculator; 34 | 35 | // create from datetime objects 36 | $zodiac = Calculator::make(new DateTime('1977-03-15')); 37 | 38 | // create from carbon objects 39 | $zodiac = Calculator::make(Carbon::yesterday()); 40 | ``` 41 | 42 | Continue reading to learn what you can do with the [zodiac objects](/v3/api/zodiac). 43 | -------------------------------------------------------------------------------- /zodiac/v4/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v4/api/zodiac.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Zodiac" 3 | subtitle: "Working with Zodiac Objects" 4 | sort: 1 5 | --- 6 | 7 | [TOC] 8 | 9 | The zodiac objects returned from the [calculator](/v3/api/calculator) can be used in the following ways. 10 | 11 | ### Zodiac Name 12 | 13 | > public Zodiac::name(): string 14 | 15 | Return the name of the current zodiac. This is more a identification key than a textual title. It's possible to cast the zodiac object to a string type to get the same result. 16 | 17 | ```php 18 | use Intervention\Zodiac\Calculator; 19 | 20 | // create from iso date 21 | $zodiac = Calculator::make('1977-06-17'); 22 | $name = $zodiac->name(); // gemini 23 | $name = (string) $zodiac; // get name by casting to string 24 | ``` 25 | 26 | ### Localized Title 27 | 28 | > public Zodiac::localized(?string $locale = null): string 29 | 30 | Return the localized title of the current zodiac in the given locale. The locale parameter is optional, by default the english language is returned. 31 | 32 | ```php 33 | use Intervention\Zodiac\Calculator; 34 | 35 | // create from iso date 36 | $zodiac = Calculator::make('1977-06-17'); 37 | $name = $zodiac->localized('fr'); // Gémeaux 38 | ``` 39 | 40 | ### HTML Representation 41 | 42 | > public Zodiac::html(): string 43 | 44 | Returns the [HTML UTF-8 symbol code](https://www.w3schools.com/charsets/ref_utf_symbols.asp) representing an icon of the current zodiac sign. 45 | 46 | ```php 47 | use Intervention\Zodiac\Calculator; 48 | 49 | // create from iso date 50 | $zodiac = Calculator::make('1977-06-17'); 51 | $name = $zodiac->html(); // ♊ 52 | ``` 53 | -------------------------------------------------------------------------------- /zodiac/v4/introduction/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | sort: 1 5 | --- 6 | 7 | You can install this package quickly and easily with Composer. 8 | 9 | Require the package via Composer: 10 | 11 | ```bash 12 | composer require intervention/zodiac 13 | ``` 14 | 15 | Although the library is **framework agnostic** it comes with a service provider for the [Laravel Framework](https://www.laravel.com/). Which will be discovered automatically and registers the calculator into your installation. 16 | 17 | After the installation you can start [using the calculator](/v3/api/calculator). 18 | -------------------------------------------------------------------------------- /zodiac/v4/introduction/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Zodiac" 3 | label: "Introduction" 4 | subtitle: "PHP Zodiac Sign Calculator" 5 | sort: 0 6 | --- 7 | 8 | Intervention Zodiac is a calculator for zodiac signs to resolve the respective zodiac sign from various data types. 9 | 10 | ### Code Example 11 | 12 | ```php 13 | use Intervention\Zodiac\Calculator; 14 | use DateTime; 15 | use Carbon\Carbon; 16 | 17 | // get zodiac object from a date 18 | $zodiac = Calculator::make('1980-09-15'); // virgo 19 | 20 | // method takes mixed formats 21 | $zodiac = Calculator::make('first day of June 2008'); // gemini 22 | 23 | // even DateTime objects 24 | $zodiac = Calculator::make(new DateTime('1977-03-15')); // pisces 25 | 26 | // get zodiac from a Carbon 27 | $zodiac = Calculator::make(Carbon::yesterday()); 28 | ``` 29 | 30 | Read how to [install the package](/v3/introduction/installation). 31 | -------------------------------------------------------------------------------- /zodiac/v4/introduction/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v4/introduction/usage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage" 3 | subtitle: "How to Use Intervention Zodiac" 4 | sort: 2 5 | --- 6 | 7 | [TOC] 8 | 9 | ## Basic Usage 10 | 11 | Use the [calculator](/v4/api/calculator) class to calculate [zodiac signs](/v4/api/zodiac) from various date types. The method `make` reads different date types. Reed the documentation on the [calculator class](/v4/api/calculator) for more information. 12 | 13 | ### Example 14 | 15 | ```php 16 | use Intervention\Zodiac\Calculator; 17 | use Intervention\Zodiac\Zodiacs\Scorpio; 18 | 19 | $calculator = new Calculator(); 20 | $sign = $calculator->make('2000-10-27'); 21 | 22 | if ($zodiac instanceof Scorpio) { 23 | // my zodiac sign is scorpio ... 24 | } 25 | ``` 26 | 27 | ### Static Example 28 | 29 | It's also possible to start the calculation with a static call. See the following example. 30 | 31 | ```php 32 | use Intervention\Zodiac\Calculator; 33 | use Intervention\Zodiac\Zodiacs\Scorpio; 34 | 35 | $sign = Calculator::make('2000-10-27'); 36 | ``` 37 | 38 | ## Usage with Laravel Framework 39 | 40 | The package comes with an integrated bridge to the Laravel Framework and includes a service provider and facade. After the installation Laravel will automatically register the service provider. 41 | 42 | ### Example 43 | 44 | In Laravel, the `make()` method is also used. However, the base class is different since we are now working with the facade. The service providers injects the framework's translator automatically. See the following example on how to calculate a zodiac sign from a get parameter and you can start right away. 45 | 46 | ```php 47 | use Illuminate\Support\Facades\Route; 48 | use Illuminate\Http\Request; 49 | 50 | Route::get('/', function (Request $request) { 51 | $sign = Zodiac::make($request->input('birthday')); 52 | return $sign->localized(); 53 | }); 54 | ``` 55 | 56 | In Laravel the `localized()` method returns by default in the currently configured locale. 57 | 58 | ### Eloquent Model Trait 59 | 60 | By including `Intervention\Zodiac\Laravel\Traits\CanResolveZodiac` your Eloquent Model gets a new zodiac attribute, which is created based on the birthday attribute of the current model and returns a zodiac object. 61 | 62 | #### Include Trait 63 | 64 | ```php 65 | class User extends Model 66 | { 67 | // include trait 68 | use \Intervention\Zodiac\Laravel\Traits\CanResolveZodiac; 69 | 70 | // optional: If you want overwrite attribute. By default `birthday` 71 | protected $birthdayAttribute = 'date_of_birth'; 72 | } 73 | ``` 74 | 75 | #### Zodiac Attribute 76 | 77 | ```php 78 | // retrieve zodiac attribute 79 | $user = App\User::create(['birthday' => '1980-03-15']); 80 | $zodiac = $user->zodiac; // Intervention\Zodiac\Zodiacs\Pisces 81 | ``` 82 | -------------------------------------------------------------------------------- /zodiac/v4/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 4" 3 | status: "eol" 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v5/api/calculator.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Calculator" 3 | subtitle: "Using the Zodiac Calculator Class" 4 | lead: "Learn how to use the Zodiac Calculator Class to transform different date formats into zodiac sign objects including reading from scalar date types or date objects." 5 | sort: 0 6 | --- 7 | 8 | [TOC] 9 | 10 | ## Instantiation 11 | 12 | ### From Scalar Dates 13 | 14 | The calculator class can read dates from **integer types** (unix timestamp) as 15 | well as **text strings**, which can represent a relative time (`last monday`, 16 | `tomorrow`, `last day of next month`), an absolute time (`first day of June 1983`, 17 | `2011-11-11`) or an unix timestamp as string. 18 | 19 | ```php 20 | use Intervention\Zodiac\Calculator; 21 | 22 | // create from iso date 23 | $zodiac = Calculator::zodiac('1992-03-19'); 24 | 25 | // create from relative date 26 | $zodiac = Calculator::zodiac('first day of June 2008'); 27 | 28 | // create from unix timestamp integer 29 | $zodiac = Calculator::zodiac(1641719287); 30 | ``` 31 | 32 | ### From Objects 33 | 34 | You can also pass date objects (`DateTime` or `Carbon`) to instantiate new zodiac objects. 35 | 36 | ```php 37 | use Intervention\Zodiac\Calculator; 38 | use Carbon\Carbon; 39 | 40 | // create from datetime objects 41 | $zodiac = Calculator::zodiac(new DateTime('1977-03-15')); 42 | 43 | // create from carbon objects 44 | $zodiac = Calculator::zodiac(Carbon::yesterday()); 45 | ``` 46 | 47 | Continue reading to learn what you can do with the [zodiac objects](/v5/api/zodiac). 48 | -------------------------------------------------------------------------------- /zodiac/v5/api/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Api" 3 | sort: 1 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v5/api/zodiac.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Zodiac" 3 | subtitle: "Working with Zodiac Objects" 4 | lead: "Discover how to use the zodiac objects returned by the Intervention Image Zodiac Calculator. Generate localized contents and use a compatibility calculator based on astrological theory." 5 | sort: 1 6 | --- 7 | 8 | [TOC] 9 | 10 | ### Zodiac Name 11 | 12 | > public Zodiac::name(): string 13 | 14 | Return the name of the current zodiac. This is more a identification key than a 15 | textual title. It's possible to cast the zodiac object to a string type to get 16 | the same result. 17 | 18 | ```php 19 | use Intervention\Zodiac\Calculator; 20 | 21 | // create from iso date 22 | $zodiac = Calculator::make('1977-06-17'); 23 | $name = $zodiac->name(); // "gemini" 24 | $name = (string) $zodiac; // "gemini" 25 | ``` 26 | 27 | ### Localized Title 28 | 29 | > public Zodiac::localized(?string $locale = null): string 30 | 31 | Return the localized title of the current zodiac in the given locale. The 32 | locale parameter is optional, by default the english language is returned. 33 | 34 | ```php 35 | use Intervention\Zodiac\Calculator; 36 | 37 | // create from iso date 38 | $zodiac = Calculator::make('1977-06-17'); 39 | $name = $zodiac->localized('fr'); // Gémeaux 40 | ``` 41 | 42 | ### HTML Representation 43 | 44 | > public Zodiac::html(): string 45 | 46 | Returns the [HTML UTF-8 symbol 47 | code](https://www.w3schools.com/charsets/ref_utf_symbols.asp) representing an 48 | icon of the current zodiac sign. 49 | 50 | ```php 51 | use Intervention\Zodiac\Calculator; 52 | 53 | // create from iso date 54 | $zodiac = Calculator::make('1977-06-17'); 55 | $name = $zodiac->html(); // ♊ 56 | ``` 57 | 58 | ### Zodiac Sign Compatibility 59 | 60 | > public Zodiac::compatibility(ZodiacInterface $zodiac): float 61 | 62 | This method calculates how a person with the current star sign matches another 63 | person with the given sign according to astrological theory. 64 | 65 | The factor is returned as a float value of `0-1`, with a higher value 66 | representing more compatibility. 67 | 68 | This value is completely made up, so don't plan your life decisions around it. 69 | 70 | 71 | ```php 72 | use Intervention\Zodiac\Calculator; 73 | 74 | $gemini = Calculator::make('1997-06-17'); // Intervention\Zodiac\Zodiacs\Gemini 75 | $virgo = Calculator::make('2000-09-10'); // Intervention\Zodiac\Zodiacs\Virgo 76 | 77 | $factor = $gemini->compatibility($virgo); 78 | ``` 79 | -------------------------------------------------------------------------------- /zodiac/v5/introduction/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation" 3 | subtitle: "Installation with Composer" 4 | lead: "Learn how to install Intervention Zodiac for PHP with Composer and discover how to use the library with the Laravel framework." 5 | sort: 1 6 | --- 7 | 8 | Use [Composer](https://getcomposer.org) for installation by running the following command. 9 | 10 | ```bash 11 | composer require intervention/zodiac 12 | ``` 13 | 14 | Although the library is **framework agnostic** it comes with a service provider 15 | for the [Laravel Framework](https://www.laravel.com/). Which will be discovered 16 | automatically and registers the calculator into your installation. 17 | 18 | After the installation you can start [using the calculator](/v5/api/calculator). 19 | -------------------------------------------------------------------------------- /zodiac/v5/introduction/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Intervention Zodiac" 3 | label: "Introduction" 4 | subtitle: "PHP Zodiac Sign Calculator" 5 | lead: "Intervention Zodiac is a calculator for zodiac signs to resolve the respective star sign from various data types." 6 | sort: 0 7 | --- 8 | 9 | ### Code Examples 10 | 11 | ```php 12 | use Intervention\Zodiac\Calculator; 13 | use DateTime; 14 | use Carbon\Carbon; 15 | 16 | // calculate zodiac sign from a string date 17 | $zodiac = Calculator::zodiac('1980-09-15'); // virgo 18 | 19 | // calculate zodiac sign from a string date 20 | $zodiac = Calculator::zodiac('first day of June 2008'); // gemini 21 | 22 | // calculate zodiac sign from DateTime object 23 | $zodiac = Calculator::zodiac(new DateTime('1977-03-15')); // pisces 24 | 25 | // get zodiac from a Carbon object 26 | $zodiac = Calculator::zodiac(Carbon::yesterday()); 27 | 28 | // get zodiac from a Carbon object 29 | $zodiac = Calculator::zodiac(228268800); 30 | ``` 31 | 32 | ```php 33 | use Intervention\Zodiac\Calculator; 34 | use DateTime; 35 | use Carbon\Carbon; 36 | 37 | // calculate zodiac sing 38 | $zodiac = Calculator::zodiac('1977-06-17'); 39 | 40 | $name = $zodiac->name(); // 'gemini' 41 | $html = $zodiac->html(); // '♊︎' 42 | $localized = $zodiac->localized('fr'); // Gémeaux 43 | $compatibility = $zodiac->compatibility($zodiac); // 6 44 | ``` 45 | 46 | Read how to [install the package](/v5/introduction/installation). 47 | -------------------------------------------------------------------------------- /zodiac/v5/introduction/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Getting Started" 3 | sort: 0 4 | --- 5 | -------------------------------------------------------------------------------- /zodiac/v5/introduction/usage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Usage" 3 | subtitle: "How to Use Intervention Zodiac" 4 | lead: "Explore Intervention Zodiac's basic usage, static methods, Laravel integration, and Eloquent Model traits for seamless zodiac attribute generation including code examples for quick implementation." 5 | sort: 2 6 | --- 7 | 8 | [TOC] 9 | 10 | ## Basic Usage 11 | 12 | Use the [calculator](/v5/api/calculator) class to calculate [zodiac 13 | signs](/v5/api/zodiac) from various date types. The method `zodiac()` acts 14 | as a central starting point. Read the documentation on the [calculator 15 | class](/v5/api/calculator) for more information. 16 | 17 | ### Example 18 | 19 | ```php 20 | use Intervention\Zodiac\Calculator; 21 | use Intervention\Zodiac\Zodiacs\Scorpio; 22 | 23 | $calculator = new Calculator(); 24 | $sign = $calculator->zodiac('2000-10-27'); 25 | 26 | if ($sign instanceof Scorpio) { 27 | // zodiac sign is scorpio ... 28 | } 29 | ``` 30 | 31 | ### Static Example 32 | 33 | It's also possible to start the calculation with a static call. See the 34 | following example. 35 | 36 | ```php 37 | use Intervention\Zodiac\Calculator; 38 | 39 | $sign = Calculator::zodiac('2000-10-27'); 40 | ``` 41 | 42 | ## Usage with Laravel Framework 43 | 44 | The package comes with an integrated bridge to the Laravel Framework and 45 | includes a service provider and facade. After the installation Laravel will 46 | automatically register the service provider. 47 | 48 | ### Example 49 | 50 | In Laravel, the `make()` method is used. However, the base class is 51 | different since we are now working with the facade. The service providers 52 | injects the framework's translator automatically. See the following example on 53 | how to calculate a zodiac sign from a get parameter and you can start right 54 | away. 55 | 56 | ```php 57 | use Illuminate\Support\Facades\Route; 58 | use Illuminate\Http\Request; 59 | use Intervention\Zodiac\Laravel\ZodiacFacade; 60 | 61 | Route::get('/', function (Request $request) { 62 | $sign = ZodiacFacade::make($request->input('birthday')); 63 | return $sign->localized(); 64 | }); 65 | ``` 66 | 67 | In Laravel the `localized()` method returns by default in the currently 68 | configured locale. 69 | 70 | ### Eloquent Model Trait 71 | 72 | By including `Intervention\Zodiac\Laravel\Traits\CanResolveZodiac` your 73 | Eloquent Model gets a new zodiac attribute, which is created based on the 74 | birthday attribute of the current model and returns a zodiac object. 75 | 76 | #### Include Trait 77 | 78 | ```php 79 | class User extends Model 80 | { 81 | // include trait 82 | use \Intervention\Zodiac\Laravel\Traits\CanResolveZodiac; 83 | 84 | // optional: If you want overwrite attribute. By default `birthday` 85 | protected string $birthdayAttribute = 'date_of_birth'; 86 | } 87 | ``` 88 | 89 | #### Zodiac Attribute 90 | 91 | ```php 92 | // retrieve zodiac attribute 93 | $user = App\User::create(['birthday' => '1980-03-15']); 94 | $zodiac = $user->zodiac; // Intervention\Zodiac\Zodiacs\Pisces 95 | ``` 96 | -------------------------------------------------------------------------------- /zodiac/v5/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Version 5" 3 | status: "stable" 4 | --- 5 | --------------------------------------------------------------------------------