-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HasOptions.php
executable file
·164 lines (137 loc) · 3.25 KB
/
HasOptions.php
1
2
3
4
5
6
7
8
9
10
11
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
declare(strict_types=1);
namespace AneesKhan47\CloudflareImageResizing\Concerns;
trait HasOptions
{
/**
* The image URL.
*/
private ?string $url = null;
/**
* The image options.
*/
private array $options = [];
/**
* Set the image URL.
*
* @param string $url The image URL.
*/
public function url(string $url): static
{
$this->url = $url;
return $this;
}
/**
* Set the image anim.
*
* @param bool $anim Whether to animate the image.
*
* @see https://developers.cloudflare.com/images/image-resizing/url-format/#anim
*/
public function anim(bool $anim): static
{
$this->options['anim'] = $anim;
return $this;
}
/**
* Set the image background.
*
* @param string $background The background color in css format. hex, rgb, rgba, hsl, hsla.
*
* @see https://developers.cloudflare.com/images/image-resizing/url-format/#background
*/
public function background(string $background): static
{
$this->options['background'] = $background;
return $this;
}
/**
* Set the image blur.
*
* @param int $blur The blur radius between 1 (slight blur) and 250 (maximum).
*
* @see https://developers.cloudflare.com/images/image-resizing/url-format/#blur
*/
public function blur(int $blur): static
{
$this->options['blur'] = $blur;
return $this;
}
/**
* Set the image brightness.
*
* @param string $brightness The brightness value of 1.0 equals no change, a value of 0.5 equals half brightness, and a value of 2.0 equals twice as bright. 0 is ignored.
*/
public function brightness(string $brightness): static
{
$this->options['brightness'] = $brightness;
return $this;
}
/**
* Set the image format.
*/
public function format(string $format): static
{
$this->options['format'] = $format;
return $this;
}
/**
* Set the image format to avif.
*/
public function avif(): static
{
return $this->format('avif');
}
/**
* Set the image format to webp.
*/
public function webp(): static
{
return $this->format('webp');
}
/**
* Set the image format to jpeg.
*/
public function jpeg(): static
{
return $this->format('jpeg');
}
/**
* Set the image format to baseline-jpeg.
*/
public function baselineJpeg(): static
{
return $this->format('baseline-jpeg');
}
/**
* Set the image format to json.
*/
public function json(): static
{
return $this->format('json');
}
/**
* Set the image quality.
*/
public function quality(int $quality): static
{
$this->options['quality'] = $quality;
return $this;
}
/**
* Set the image width.
*/
public function width(int $width): static
{
$this->options['width'] = $width;
return $this;
}
/**
* Set the image height.
*/
public function height(int $height): static
{
$this->options['height'] = $height;
return $this;
}
}