-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiscOptions.php
More file actions
176 lines (153 loc) · 4.26 KB
/
MiscOptions.php
File metadata and controls
176 lines (153 loc) · 4.26 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
<?php
declare(strict_types=1);
namespace HosmelQ\Imgproxy\Concerns;
use HosmelQ\Imgproxy\HashsumType;
use HosmelQ\Imgproxy\OptionName;
use HosmelQ\Imgproxy\Support\ValueFormatter;
trait MiscOptions
{
/**
* Add cache buster.
*/
public function cachebuster(string $value): self
{
return $this->withOption(OptionName::Cachebuster, [$value]);
}
/**
* Set DPI metadata.
*/
public function dpi(int $dpi): self
{
return $this->withOption(OptionName::Dpi, [(string) $dpi]);
}
/**
* Enforce embedded thumbnail usage.
*/
public function enforceThumbnail(bool $enforce = true): self
{
return $this->withOption(OptionName::EnforceThumbnail, [$this->bool($enforce)]);
}
/**
* Set expiry timestamp.
*/
public function expires(int $timestamp): self
{
return $this->withOption(OptionName::Expires, [(string) $timestamp]);
}
/**
* Use fallback image URL.
*/
public function fallbackImageUrl(string $url): self
{
return $this->withOption(OptionName::FallbackImageUrl, [ValueFormatter::base64UrlEncode($url)]);
}
/**
* Set filename for Content-Disposition.
*/
public function filename(string $filename, null|bool $encoded = null): self
{
$value = $encoded === true ? ValueFormatter::base64UrlEncode($filename) : rawurlencode($filename);
return $this->withOption(OptionName::Filename, [
$value,
$this->boolOrNull($encoded),
]);
}
/**
* Configure hashsum validation.
*/
public function hashsum(HashsumType $type, null|string $hash = null): self
{
return $this->withOption(OptionName::Hashsum, [
$type->value,
$hash,
]);
}
/**
* Preserve copyright metadata.
*/
public function keepCopyright(bool $keep = true): self
{
return $this->withOption(OptionName::KeepCopyright, [$this->bool($keep)]);
}
/**
* Limit animation frame resolution.
*/
public function maxAnimationFrameResolution(int $resolution): self
{
return $this->withOption(OptionName::MaxAnimationFrameResolution, [(string) $resolution]);
}
/**
* Limit animation frames.
*/
public function maxAnimationFrames(int $frames): self
{
return $this->withOption(OptionName::MaxAnimationFrames, [(string) $frames]);
}
/**
* Limit result dimension.
*/
public function maxResultDimension(int $dimension): self
{
return $this->withOption(OptionName::MaxResultDimension, [(string) $dimension]);
}
/**
* Limit source file size.
*/
public function maxSrcFileSize(int $size): self
{
return $this->withOption(OptionName::MaxSrcFileSize, [(string) $size]);
}
/**
* Limit source resolution.
*/
public function maxSrcResolution(int $resolution): self
{
return $this->withOption(OptionName::MaxSrcResolution, [(string) $resolution]);
}
/**
* Apply presets.
*
* @param list<string> $presets
*/
public function preset(array $presets): self
{
return $this->withOption(OptionName::Preset, $presets);
}
/**
* Return raw source.
*/
public function raw(bool $raw = true): self
{
return $this->withOption(OptionName::Raw, [$this->bool($raw)]);
}
/**
* Return as attachment.
*/
public function returnAttachment(bool $returnAttachment = true): self
{
return $this->withOption(OptionName::ReturnAttachment, [$this->bool($returnAttachment)]);
}
/**
* Skip processing for specific extensions.
*
* @param list<string> $extensions
*/
public function skipProcessing(array $extensions): self
{
return $this->withOption(OptionName::SkipProcessing, $extensions);
}
/**
* Strip color profile.
*/
public function stripColorProfile(bool $strip = true): self
{
return $this->withOption(OptionName::StripColorProfile, [$this->bool($strip)]);
}
/**
* Strip metadata.
*/
public function stripMetadata(bool $strip = true): self
{
return $this->withOption(OptionName::StripMetadata, [$this->bool($strip)]);
}
}