imgproxy 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +8 -0
- data/CHANGELOG.md +74 -0
- data/README.md +176 -135
- data/UPGRADE.md +136 -0
- data/docs/info_options.md +223 -0
- data/docs/processing_options.md +724 -0
- data/docs/yard/fix_pictures.rb +25 -0
- data/docs/yard/github_alerts.rb +16 -0
- data/docs/yard/relative_markdown_links.rb +31 -0
- data/lib/imgproxy/config.rb +96 -41
- data/lib/imgproxy/extensions/active_storage.rb +6 -4
- data/lib/imgproxy/extensions/shrine.rb +6 -4
- data/lib/imgproxy/option_aliases/info.rb +33 -0
- data/lib/imgproxy/option_aliases/processing.rb +74 -0
- data/lib/imgproxy/options_builders/base.rb +54 -0
- data/lib/imgproxy/options_builders/info.rb +52 -0
- data/lib/imgproxy/options_builders/processing.rb +150 -0
- data/lib/imgproxy/options_casters/adjust.rb +3 -1
- data/lib/imgproxy/options_casters/alpha.rb +27 -0
- data/lib/imgproxy/options_casters/array.rb +3 -1
- data/lib/imgproxy/options_casters/autoquality.rb +28 -0
- data/lib/imgproxy/options_casters/average.rb +27 -0
- data/lib/imgproxy/options_casters/background.rb +27 -0
- data/lib/imgproxy/options_casters/base64.rb +2 -0
- data/lib/imgproxy/options_casters/blur_detections.rb +28 -0
- data/lib/imgproxy/options_casters/blurhash.rb +21 -0
- data/lib/imgproxy/options_casters/bool.rb +3 -1
- data/lib/imgproxy/options_casters/crop.rb +3 -1
- data/lib/imgproxy/options_casters/dominant_colors.rb +27 -0
- data/lib/imgproxy/options_casters/draw_detections.rb +28 -0
- data/lib/imgproxy/options_casters/extend.rb +3 -1
- data/lib/imgproxy/options_casters/filename.rb +31 -0
- data/lib/imgproxy/options_casters/float.rb +3 -1
- data/lib/imgproxy/options_casters/format_quality.rb +19 -0
- data/lib/imgproxy/options_casters/gradient.rb +31 -0
- data/lib/imgproxy/options_casters/gravity.rb +20 -6
- data/lib/imgproxy/options_casters/group.rb +2 -0
- data/lib/imgproxy/options_casters/hashsum.rb +24 -0
- data/lib/imgproxy/options_casters/integer.rb +2 -0
- data/lib/imgproxy/options_casters/jpeg_options.rb +3 -1
- data/lib/imgproxy/options_casters/padding.rb +41 -0
- data/lib/imgproxy/options_casters/png_options.rb +3 -1
- data/lib/imgproxy/options_casters/resize.rb +3 -1
- data/lib/imgproxy/options_casters/size.rb +3 -1
- data/lib/imgproxy/options_casters/string.rb +2 -0
- data/lib/imgproxy/options_casters/trim.rb +3 -1
- data/lib/imgproxy/options_casters/unsharp_masking.rb +25 -0
- data/lib/imgproxy/options_casters/video_thumbnail_tile.rb +34 -0
- data/lib/imgproxy/options_casters/watermark.rb +5 -4
- data/lib/imgproxy/options_casters/watermark_size.rb +21 -0
- data/lib/imgproxy/options_casters/{gif_options.rb → webp_options.rb} +6 -5
- data/lib/imgproxy/options_casters/zoom.rb +27 -0
- data/lib/imgproxy/service_config.rb +111 -0
- data/lib/imgproxy/trim_array.rb +2 -0
- data/lib/imgproxy/url_adapters/active_storage.rb +2 -0
- data/lib/imgproxy/url_adapters/shrine.rb +8 -2
- data/lib/imgproxy/url_adapters.rb +3 -0
- data/lib/imgproxy/url_builders/base.rb +184 -0
- data/lib/imgproxy/url_builders/info.rb +44 -0
- data/lib/imgproxy/url_builders/processing.rb +59 -0
- data/lib/imgproxy/version.rb +3 -1
- data/lib/imgproxy.rb +19 -57
- data/logo/logo-dark.svg +22 -0
- data/logo/logo-light.svg +31 -0
- metadata +70 -32
- data/lib/imgproxy/builder.rb +0 -140
- data/lib/imgproxy/options.rb +0 -119
- data/lib/imgproxy/options_aliases.rb +0 -45
data/logo/logo-light.svg
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="266" height="100" fill="none">
|
2
|
+
<g clip-path="url(#a)">
|
3
|
+
<path fill="#000" d="M94.056 42.55v2.915h5.803v11.648h-5.803v2.915h14.733v-2.915h-5.69V42.549h-9.043Zm4.916-4.367c0 1.423.83 2.423 2.451 2.423 1.619 0 2.45-1 2.45-2.423 0-1.422-.831-2.422-2.45-2.422-1.62 0-2.451 1-2.451 2.422Zm14.479 4.366v17.465h3.239V48.746c0-2.507.859-3.633 2.775-3.633 1.915 0 2.774 1.14 2.774 3.633v11.268h3.24V48.746c0-2.535.859-3.633 2.775-3.633 1.915 0 2.774 1.112 2.774 3.633v11.268h3.24V47.845c0-3.465-2.099-5.76-5.24-5.76-1.648 0-3.155.732-4.014 1.915h-.591c-.86-1.225-2.155-1.916-3.747-1.916-1.648 0-2.887.578-3.563 1.634h-.409V42.55h-3.253Zm42.704 16.902V42.549h-3.24v1.578h-.887c-.831-1.226-2.676-2.043-4.662-2.043-4.662 0-7.774 3.437-7.774 8.62 0 5.099 3.126 8.507 7.774 8.507 1.916 0 3.775-.76 4.662-1.915h.887v1.859c0 2.676-1.887 4.253-5.07 4.253-2.535 0-4.422-1.042-5.07-2.788h-3.183c.183 3.436 3.478 5.704 8.253 5.704 5.155-.014 8.31-2.746 8.31-6.873Zm-13.324-8.747c0-3.465 1.944-5.591 5.127-5.591s5.127 2.126 5.127 5.591c0 3.465-1.944 5.592-5.127 5.592s-5.127-2.127-5.127-5.592Zm28.648-8.62c-2.127 0-4.071.874-4.887 2.212h-.888v-1.747h-3.239v23.296h3.239v-7.577h.888c.816 1.338 2.774 2.21 4.887 2.21 4.775 0 7.958-3.675 7.958-9.196s-3.183-9.197-7.958-9.197Zm-5.887 9.212c0-3.817 2-6.17 5.309-6.17 3.296 0 5.31 2.353 5.31 6.17 0 3.817-2 6.169-5.31 6.169-3.309 0-5.309-2.366-5.309-6.17Zm18.845-8.747v2.916h4.14v11.648h-4.14v2.915h13.746v-2.915h-6.366v-6.409c0-3.704 1.155-5.591 3.422-5.591 1.831 0 2.775 1.07 2.775 3.14v2.057h3.352v-2.521c0-3.55-1.915-5.705-5.07-5.705-1.676 0-3.071.634-3.831 1.803h-.888V42.55h-7.14Zm30.042 17.944c5.211 0 8.69-3.676 8.69-9.197 0-5.521-3.479-9.197-8.69-9.197-5.211 0-8.69 3.676-8.69 9.197 0 5.52 3.465 9.197 8.69 9.197Zm-5.451-9.197c0-3.817 2.071-6.17 5.451-6.17 3.394 0 5.451 2.353 5.451 6.17 0 3.817-2.057 6.169-5.451 6.169-3.394 0-5.451-2.366-5.451-6.17ZM227 60.028h3.718l4.127-6.056.324-.845h.296l.324.845 4.07 6.056h3.944l-5.747-8.591 6.099-8.888h-3.62l-4.62 6.705-.323.845h-.296l-.324-.845-4.423-6.705h-3.887l6.042 9.17-5.704 8.31Zm20.69-17.479 6.338 16.014h2.648l-1.056 2.972c-.535 1.31-1.057 1.86-2.028 1.86-1.057 0-1.62-.55-2.184-1.86h-2.943c.239 3.056 2.155 4.775 5.31 4.775 2.126 0 3.859-1.395 4.718-3.789l7.127-19.972h-3.296l-4.62 13.099h-1.267l-5.155-13.099h-3.592Z"/>
|
4
|
+
<mask id="b" width="94" height="79" x="0" y="22" maskUnits="userSpaceOnUse" style="mask-type:luminance">
|
5
|
+
<path fill="#fff" d="M.394 22.535h92.817v78.169H.394V22.535Z"/>
|
6
|
+
</mask>
|
7
|
+
<g mask="url(#b)">
|
8
|
+
<path fill="url(#c)" d="M78.493 32.732V22.535H68.31v2.831H44.535v-2.83H34.352v2.83H10.577v-2.83H.394v10.196h2.831v12.465H.395v10.197h2.83V67.86H.395v10.197h10.182v-2.845h23.775v2.831h10.183v-2.83H68.31v2.83h10.183V67.845h-2.831V55.38h2.83V45.183h-2.83V32.718h2.83v.014Zm-41.873-7.93h5.662v5.663H36.62v-5.662ZM2.662 30.466v-5.662h5.662v5.662H2.662Zm0 22.662v-5.662h5.662v5.662H2.662Zm5.662 22.648H2.662v-5.662h5.662v5.662Zm33.958 0H36.62v-5.662h5.662v5.662Zm26.028-5.099H44.535v-2.83H34.352v2.83H10.577v-2.83h-2.83V55.38h2.83V45.183h-2.83V32.718h2.83v-2.83h23.775v2.83h10.183v-2.83H68.31v2.83h2.83v12.465h-2.83V55.38h2.83v12.465h-2.83v2.831Zm7.93-.563v5.662h-5.663v-5.662h5.662Zm0-22.648v5.662h-5.663v-5.662h5.662Zm-5.663-17v-5.662h5.662v5.662h-5.662Z"/>
|
9
|
+
<path fill="#1960C4" d="M22.55 45.192v.864h.592a1.98 1.98 0 0 1 .8-.848 2.36 2.36 0 0 1 1.2-.304c.778 0 1.37.293 1.776.88.405.587.608 1.445.608 2.576v1.552h-2.544V48.68c0-.459-.086-.8-.256-1.024-.17-.235-.432-.352-.784-.352-.438 0-.763.197-.976.592-.203.395-.304.997-.304 1.808v3.072h2.8V55h-6.88v-2.224h1.664v-5.36h-1.872v-2.224h4.176ZM35.545 55v-9.808h2.496V55h-2.496Zm-3.44-4.192c0 .715.144 1.253.432 1.616.288.363.715.544 1.28.544.576 0 1.008-.181 1.296-.544.288-.363.432-.901.432-1.616h.368v3.312h-.96a2.293 2.293 0 0 1-.896.88c-.384.203-.827.304-1.328.304-.65 0-1.21-.155-1.68-.464-.459-.31-.816-.752-1.072-1.328-.245-.587-.368-1.28-.368-2.08v-6.24h2.496v5.616Zm14.019 4.448c-.49 0-.933-.107-1.328-.32a2.085 2.085 0 0 1-.88-.864h-.592V55h-2.496V41.432h2.496v4.672h.592c.192-.352.485-.635.88-.848.395-.213.837-.32 1.328-.32.79 0 1.477.213 2.064.64.597.416 1.056 1.013 1.376 1.792.32.768.48 1.68.48 2.736 0 1.045-.16 1.957-.48 2.736-.32.768-.779 1.365-1.376 1.792-.587.416-1.275.624-2.064.624Zm-2.944-5.168c0 .928.192 1.653.576 2.176.395.512.944.768 1.648.768s1.248-.256 1.632-.768c.395-.523.592-1.248.592-2.176 0-.928-.197-1.648-.592-2.16-.384-.512-.928-.768-1.632-.768-.704 0-1.253.261-1.648.784-.384.512-.576 1.227-.576 2.144Zm10.835-4.896 2.256 7.072h1.376L57.12 54.2h-2.704l-2.96-9.008h2.56Zm4.144 10.864c-.245.8-.624 1.408-1.136 1.824-.501.416-1.125.624-1.872.624-.928 0-1.659-.256-2.192-.768-.523-.512-.832-1.259-.928-2.24h2.192c.117.32.245.544.384.672a.715.715 0 0 0 .528.208.623.623 0 0 0 .496-.224c.139-.139.261-.373.368-.704l2.848-10.256h2.368L58.16 56.056Z"/>
|
10
|
+
<path fill="url(#d)" fill-rule="evenodd" d="M81.437 91.746h10.957L73.606 72.945l7.83 18.802Z" clip-rule="evenodd"/>
|
11
|
+
<path fill="url(#e)" fill-rule="evenodd" d="M73.606 72.944v26.62l7.817-7.832" clip-rule="evenodd"/>
|
12
|
+
</g>
|
13
|
+
</g>
|
14
|
+
<defs>
|
15
|
+
<linearGradient id="c" x1="39.445" x2="39.445" y1="78.046" y2="22.535" gradientUnits="userSpaceOnUse">
|
16
|
+
<stop stop-color="#1D40B2"/>
|
17
|
+
<stop offset="1" stop-color="#1680D6"/>
|
18
|
+
</linearGradient>
|
19
|
+
<linearGradient id="d" x1="76.587" x2="89.416" y1="84.063" y2="80.629" gradientUnits="userSpaceOnUse">
|
20
|
+
<stop stop-color="#1C1C1C"/>
|
21
|
+
<stop offset="1" stop-color="#3D3E3F"/>
|
22
|
+
</linearGradient>
|
23
|
+
<linearGradient id="e" x1="70.287" x2="79.541" y1="87.15" y2="84.673" gradientUnits="userSpaceOnUse">
|
24
|
+
<stop stop-color="#1C1C1C"/>
|
25
|
+
<stop offset="1" stop-color="#3D3E3F"/>
|
26
|
+
</linearGradient>
|
27
|
+
<clipPath id="a">
|
28
|
+
<path fill="#fff" d="M0 0h266v100H0z"/>
|
29
|
+
</clipPath>
|
30
|
+
</defs>
|
31
|
+
</svg>
|
metadata
CHANGED
@@ -1,113 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgproxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Sergei Aleksandrovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: benchmark-memory
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2
|
33
|
+
version: '0.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2
|
40
|
+
version: '0.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: combustion
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3
|
47
|
+
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3
|
54
|
+
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: '3.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: '3.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '6.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '6.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
84
|
+
name: rubocop-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '2.11'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '2.11'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: standard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: aws-sdk-s3
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 7.0
|
145
|
+
version: '7.0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 7.0
|
152
|
+
version: '7.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: shrine
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,57 +170,95 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.4
|
173
|
+
version: '1.4'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.4
|
180
|
+
version: '1.4'
|
181
181
|
description: A gem that easily generates imgproxy URLs for your images
|
182
182
|
email: darthsim@gmail.com
|
183
183
|
executables: []
|
184
184
|
extensions: []
|
185
185
|
extra_rdoc_files: []
|
186
186
|
files:
|
187
|
+
- ".yardopts"
|
188
|
+
- CHANGELOG.md
|
187
189
|
- LICENSE
|
188
190
|
- README.md
|
191
|
+
- UPGRADE.md
|
192
|
+
- docs/info_options.md
|
193
|
+
- docs/processing_options.md
|
194
|
+
- docs/yard/fix_pictures.rb
|
195
|
+
- docs/yard/github_alerts.rb
|
196
|
+
- docs/yard/relative_markdown_links.rb
|
189
197
|
- lib/imgproxy.rb
|
190
|
-
- lib/imgproxy/builder.rb
|
191
198
|
- lib/imgproxy/config.rb
|
192
199
|
- lib/imgproxy/extensions/active_storage.rb
|
193
200
|
- lib/imgproxy/extensions/shrine.rb
|
194
|
-
- lib/imgproxy/
|
195
|
-
- lib/imgproxy/
|
201
|
+
- lib/imgproxy/option_aliases/info.rb
|
202
|
+
- lib/imgproxy/option_aliases/processing.rb
|
203
|
+
- lib/imgproxy/options_builders/base.rb
|
204
|
+
- lib/imgproxy/options_builders/info.rb
|
205
|
+
- lib/imgproxy/options_builders/processing.rb
|
196
206
|
- lib/imgproxy/options_casters/adjust.rb
|
207
|
+
- lib/imgproxy/options_casters/alpha.rb
|
197
208
|
- lib/imgproxy/options_casters/array.rb
|
209
|
+
- lib/imgproxy/options_casters/autoquality.rb
|
210
|
+
- lib/imgproxy/options_casters/average.rb
|
211
|
+
- lib/imgproxy/options_casters/background.rb
|
198
212
|
- lib/imgproxy/options_casters/base64.rb
|
213
|
+
- lib/imgproxy/options_casters/blur_detections.rb
|
214
|
+
- lib/imgproxy/options_casters/blurhash.rb
|
199
215
|
- lib/imgproxy/options_casters/bool.rb
|
200
216
|
- lib/imgproxy/options_casters/crop.rb
|
217
|
+
- lib/imgproxy/options_casters/dominant_colors.rb
|
218
|
+
- lib/imgproxy/options_casters/draw_detections.rb
|
201
219
|
- lib/imgproxy/options_casters/extend.rb
|
220
|
+
- lib/imgproxy/options_casters/filename.rb
|
202
221
|
- lib/imgproxy/options_casters/float.rb
|
203
|
-
- lib/imgproxy/options_casters/
|
222
|
+
- lib/imgproxy/options_casters/format_quality.rb
|
223
|
+
- lib/imgproxy/options_casters/gradient.rb
|
204
224
|
- lib/imgproxy/options_casters/gravity.rb
|
205
225
|
- lib/imgproxy/options_casters/group.rb
|
226
|
+
- lib/imgproxy/options_casters/hashsum.rb
|
206
227
|
- lib/imgproxy/options_casters/integer.rb
|
207
228
|
- lib/imgproxy/options_casters/jpeg_options.rb
|
229
|
+
- lib/imgproxy/options_casters/padding.rb
|
208
230
|
- lib/imgproxy/options_casters/png_options.rb
|
209
231
|
- lib/imgproxy/options_casters/resize.rb
|
210
232
|
- lib/imgproxy/options_casters/size.rb
|
211
233
|
- lib/imgproxy/options_casters/string.rb
|
212
234
|
- lib/imgproxy/options_casters/trim.rb
|
235
|
+
- lib/imgproxy/options_casters/unsharp_masking.rb
|
236
|
+
- lib/imgproxy/options_casters/video_thumbnail_tile.rb
|
213
237
|
- lib/imgproxy/options_casters/watermark.rb
|
238
|
+
- lib/imgproxy/options_casters/watermark_size.rb
|
239
|
+
- lib/imgproxy/options_casters/webp_options.rb
|
240
|
+
- lib/imgproxy/options_casters/zoom.rb
|
241
|
+
- lib/imgproxy/service_config.rb
|
214
242
|
- lib/imgproxy/trim_array.rb
|
215
243
|
- lib/imgproxy/url_adapters.rb
|
216
244
|
- lib/imgproxy/url_adapters/active_storage.rb
|
217
245
|
- lib/imgproxy/url_adapters/shrine.rb
|
246
|
+
- lib/imgproxy/url_builders/base.rb
|
247
|
+
- lib/imgproxy/url_builders/info.rb
|
248
|
+
- lib/imgproxy/url_builders/processing.rb
|
218
249
|
- lib/imgproxy/version.rb
|
250
|
+
- logo/logo-dark.svg
|
251
|
+
- logo/logo-light.svg
|
219
252
|
homepage: https://github.com/imgproxy/imgproxy.rb
|
220
253
|
licenses:
|
221
254
|
- MIT
|
222
255
|
metadata:
|
223
256
|
rubygems_mfa_required: 'true'
|
257
|
+
bug_tracker_uri: http://github.com/imgproxy/imgproxy.rb/issues
|
258
|
+
changelog_uri: https://github.com/imgproxy/imgproxy.rb/blob/master/CHANGELOG.md
|
259
|
+
documentation_uri: http://github.com/imgproxy/imgproxy.rb
|
260
|
+
homepage_uri: http://github.com/imgproxy/imgproxy.rb
|
261
|
+
source_code_uri: http://github.com/imgproxy/imgproxy.rb
|
224
262
|
post_install_message:
|
225
263
|
rdoc_options: []
|
226
264
|
require_paths:
|
@@ -236,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
274
|
- !ruby/object:Gem::Version
|
237
275
|
version: '0'
|
238
276
|
requirements: []
|
239
|
-
rubygems_version: 3.
|
277
|
+
rubygems_version: 3.4.10
|
240
278
|
signing_key:
|
241
279
|
specification_version: 4
|
242
280
|
summary: imgproxy URL generator
|
data/lib/imgproxy/builder.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
require "openssl"
|
2
|
-
require "base64"
|
3
|
-
require "erb"
|
4
|
-
|
5
|
-
require "imgproxy/options"
|
6
|
-
require "imgproxy/options_aliases"
|
7
|
-
|
8
|
-
module Imgproxy
|
9
|
-
# Builds imgproxy URL
|
10
|
-
#
|
11
|
-
# builder = Imgproxy::Builder.new(
|
12
|
-
# width: 500,
|
13
|
-
# height: 400,
|
14
|
-
# resizing_type: :fill,
|
15
|
-
# sharpen: 0.5
|
16
|
-
# )
|
17
|
-
#
|
18
|
-
# builder.url_for("http://images.example.com/images/image1.jpg")
|
19
|
-
# builder.url_for("http://images.example.com/images/image2.jpg")
|
20
|
-
class Builder
|
21
|
-
# @param [Hash] options Processing options
|
22
|
-
# @see Imgproxy.url_for
|
23
|
-
def initialize(options = {})
|
24
|
-
options = options.dup
|
25
|
-
|
26
|
-
extract_builder_options(options)
|
27
|
-
|
28
|
-
@options = Imgproxy::Options.new(options)
|
29
|
-
@format = @options.delete(:format)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Genrates imgproxy URL
|
33
|
-
#
|
34
|
-
# @return [String] imgproxy URL
|
35
|
-
# @param [String,URI, Object] image Source image URL or object applicable for
|
36
|
-
# the configured URL adapters
|
37
|
-
# @see Imgproxy.url_for
|
38
|
-
def url_for(image)
|
39
|
-
path = [*processing_options, url(image, ext: @format)].join("/")
|
40
|
-
signature = sign_path(path)
|
41
|
-
|
42
|
-
File.join(Imgproxy.config.endpoint.to_s, signature, path)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Genrates imgproxy info URL
|
46
|
-
#
|
47
|
-
# @return [String] imgproxy info URL
|
48
|
-
# @param [String,URI, Object] image Source image URL or object applicable for
|
49
|
-
# the configured URL adapters
|
50
|
-
# @see Imgproxy.info_url_for
|
51
|
-
def info_url_for(image)
|
52
|
-
path = url(image)
|
53
|
-
signature = sign_path(path)
|
54
|
-
|
55
|
-
File.join(Imgproxy.config.endpoint.to_s, "info", signature, path)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
NEED_ESCAPE_RE = /[@?% ]|[^\p{Ascii}]/.freeze
|
61
|
-
|
62
|
-
def extract_builder_options(options)
|
63
|
-
@use_short_options = not_nil_or(options.delete(:use_short_options), config.use_short_options)
|
64
|
-
@base64_encode_url = not_nil_or(options.delete(:base64_encode_url), config.base64_encode_urls)
|
65
|
-
@escape_plain_url =
|
66
|
-
not_nil_or(options.delete(:escape_plain_url), config.always_escape_plain_urls)
|
67
|
-
end
|
68
|
-
|
69
|
-
def processing_options
|
70
|
-
@processing_options ||= @options.map do |key, value|
|
71
|
-
[option_alias(key), value].join(":")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def url(image, ext: nil)
|
76
|
-
url = config.url_adapters.url_of(image)
|
77
|
-
|
78
|
-
@base64_encode_url ? base64_url_for(url, ext: ext) : plain_url_for(url, ext: ext)
|
79
|
-
end
|
80
|
-
|
81
|
-
def plain_url_for(url, ext: nil)
|
82
|
-
escaped_url = need_escape_url?(url) ? ERB::Util.url_encode(url) : url
|
83
|
-
|
84
|
-
ext ? "plain/#{escaped_url}@#{ext}" : "plain/#{escaped_url}"
|
85
|
-
end
|
86
|
-
|
87
|
-
def base64_url_for(url, ext: nil)
|
88
|
-
encoded_url = Base64.urlsafe_encode64(url).tr("=", "").scan(/.{1,16}/).join("/")
|
89
|
-
|
90
|
-
ext ? "#{encoded_url}.#{ext}" : encoded_url
|
91
|
-
end
|
92
|
-
|
93
|
-
def need_escape_url?(url)
|
94
|
-
@escape_plain_url || url.match?(NEED_ESCAPE_RE)
|
95
|
-
end
|
96
|
-
|
97
|
-
def option_alias(name)
|
98
|
-
return name unless @use_short_options
|
99
|
-
|
100
|
-
Imgproxy::OPTIONS_ALIASES.fetch(name, name)
|
101
|
-
end
|
102
|
-
|
103
|
-
def sign_path(path)
|
104
|
-
return "unsafe" unless ready_to_sign?
|
105
|
-
|
106
|
-
digest = OpenSSL::HMAC.digest(
|
107
|
-
OpenSSL::Digest.new("sha256"),
|
108
|
-
signature_key,
|
109
|
-
"#{signature_salt}/#{path}",
|
110
|
-
)[0, signature_size]
|
111
|
-
|
112
|
-
Base64.urlsafe_encode64(digest).tr("=", "")
|
113
|
-
end
|
114
|
-
|
115
|
-
def ready_to_sign?
|
116
|
-
!(signature_key.nil? || signature_salt.nil? ||
|
117
|
-
signature_key.empty? || signature_salt.empty?)
|
118
|
-
end
|
119
|
-
|
120
|
-
def signature_key
|
121
|
-
config.raw_key
|
122
|
-
end
|
123
|
-
|
124
|
-
def signature_salt
|
125
|
-
config.raw_salt
|
126
|
-
end
|
127
|
-
|
128
|
-
def signature_size
|
129
|
-
config.signature_size
|
130
|
-
end
|
131
|
-
|
132
|
-
def config
|
133
|
-
Imgproxy.config
|
134
|
-
end
|
135
|
-
|
136
|
-
def not_nil_or(value, fallback)
|
137
|
-
value.nil? ? fallback : value
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
data/lib/imgproxy/options.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
require "imgproxy/trim_array"
|
2
|
-
require "imgproxy/options_casters/string"
|
3
|
-
require "imgproxy/options_casters/integer"
|
4
|
-
require "imgproxy/options_casters/float"
|
5
|
-
require "imgproxy/options_casters/bool"
|
6
|
-
require "imgproxy/options_casters/array"
|
7
|
-
require "imgproxy/options_casters/base64"
|
8
|
-
require "imgproxy/options_casters/resize"
|
9
|
-
require "imgproxy/options_casters/size"
|
10
|
-
require "imgproxy/options_casters/extend"
|
11
|
-
require "imgproxy/options_casters/gravity"
|
12
|
-
require "imgproxy/options_casters/crop"
|
13
|
-
require "imgproxy/options_casters/trim"
|
14
|
-
require "imgproxy/options_casters/adjust"
|
15
|
-
require "imgproxy/options_casters/watermark"
|
16
|
-
require "imgproxy/options_casters/jpeg_options"
|
17
|
-
require "imgproxy/options_casters/png_options"
|
18
|
-
require "imgproxy/options_casters/gif_options"
|
19
|
-
|
20
|
-
module Imgproxy
|
21
|
-
# Formats and regroups processing options
|
22
|
-
class Options < Hash
|
23
|
-
using TrimArray
|
24
|
-
|
25
|
-
CASTERS = {
|
26
|
-
resize: Imgproxy::OptionsCasters::Resize,
|
27
|
-
size: Imgproxy::OptionsCasters::Size,
|
28
|
-
resizing_type: Imgproxy::OptionsCasters::String,
|
29
|
-
resizing_algorithm: Imgproxy::OptionsCasters::String,
|
30
|
-
width: Imgproxy::OptionsCasters::Integer,
|
31
|
-
height: Imgproxy::OptionsCasters::Integer,
|
32
|
-
dpr: Imgproxy::OptionsCasters::Float,
|
33
|
-
enlarge: Imgproxy::OptionsCasters::Bool,
|
34
|
-
extend: Imgproxy::OptionsCasters::Extend,
|
35
|
-
gravity: Imgproxy::OptionsCasters::Gravity,
|
36
|
-
crop: Imgproxy::OptionsCasters::Crop,
|
37
|
-
padding: Imgproxy::OptionsCasters::Array,
|
38
|
-
trim: Imgproxy::OptionsCasters::Trim,
|
39
|
-
rotate: Imgproxy::OptionsCasters::Integer,
|
40
|
-
quality: Imgproxy::OptionsCasters::Integer,
|
41
|
-
max_bytes: Imgproxy::OptionsCasters::Integer,
|
42
|
-
background: Imgproxy::OptionsCasters::Array,
|
43
|
-
background_alpha: Imgproxy::OptionsCasters::Float,
|
44
|
-
adjust: Imgproxy::OptionsCasters::Adjust,
|
45
|
-
brightness: Imgproxy::OptionsCasters::Integer,
|
46
|
-
contrast: Imgproxy::OptionsCasters::Float,
|
47
|
-
saturation: Imgproxy::OptionsCasters::Float,
|
48
|
-
blur: Imgproxy::OptionsCasters::Float,
|
49
|
-
sharpen: Imgproxy::OptionsCasters::Float,
|
50
|
-
pixelate: Imgproxy::OptionsCasters::Integer,
|
51
|
-
unsharpening: Imgproxy::OptionsCasters::String,
|
52
|
-
watermark: Imgproxy::OptionsCasters::Watermark,
|
53
|
-
watermark_url: Imgproxy::OptionsCasters::Base64,
|
54
|
-
style: Imgproxy::OptionsCasters::Base64,
|
55
|
-
jpeg_options: Imgproxy::OptionsCasters::JpegOptions,
|
56
|
-
png_options: Imgproxy::OptionsCasters::PngOptions,
|
57
|
-
gif_options: Imgproxy::OptionsCasters::GifOptions,
|
58
|
-
page: Imgproxy::OptionsCasters::Integer,
|
59
|
-
video_thumbnail_second: Imgproxy::OptionsCasters::Integer,
|
60
|
-
preset: Imgproxy::OptionsCasters::Array,
|
61
|
-
cachebuster: Imgproxy::OptionsCasters::String,
|
62
|
-
strip_metadata: Imgproxy::OptionsCasters::Bool,
|
63
|
-
strip_color_profile: Imgproxy::OptionsCasters::Bool,
|
64
|
-
auto_rotate: Imgproxy::OptionsCasters::Bool,
|
65
|
-
filename: Imgproxy::OptionsCasters::String,
|
66
|
-
format: Imgproxy::OptionsCasters::String,
|
67
|
-
return_attachment: Imgproxy::OptionsCasters::Bool,
|
68
|
-
expires: Imgproxy::OptionsCasters::Integer,
|
69
|
-
}.freeze
|
70
|
-
|
71
|
-
META = %i[size resize adjust].freeze
|
72
|
-
|
73
|
-
# @param options [Hash] raw processing options
|
74
|
-
def initialize(options)
|
75
|
-
super()
|
76
|
-
|
77
|
-
# Options order hack: initialize known and meta options with nil value to preserve order
|
78
|
-
CASTERS.each_key { |n| self[n] = nil if options.key?(n) || META.include?(n) }
|
79
|
-
|
80
|
-
options.each do |name, value|
|
81
|
-
caster = CASTERS[name]
|
82
|
-
self[name] = caster ? caster.cast(value) : unwrap_hash(value)
|
83
|
-
end
|
84
|
-
|
85
|
-
group_resizing_opts
|
86
|
-
group_adjust_opts
|
87
|
-
|
88
|
-
compact!
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
def unwrap_hash(raw)
|
94
|
-
return raw unless raw.is_a?(Hash)
|
95
|
-
|
96
|
-
raw.flat_map do |_key, val|
|
97
|
-
unwrap_hash(val)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def group_resizing_opts
|
102
|
-
return unless self[:width] && self[:height] && !self[:size] && !self[:resize]
|
103
|
-
|
104
|
-
self[:size] = extract_and_trim_nils(:width, :height, :enlarge, :extend)
|
105
|
-
self[:resize] = [delete(:resizing_type), *delete(:size)] if self[:resizing_type]
|
106
|
-
end
|
107
|
-
|
108
|
-
def group_adjust_opts
|
109
|
-
return if self[:adjust]
|
110
|
-
return unless values_at(:brightness, :contrast, :saturation).count { |o| o } > 1
|
111
|
-
|
112
|
-
self[:adjust] = extract_and_trim_nils(:brightness, :contrast, :saturation)
|
113
|
-
end
|
114
|
-
|
115
|
-
def extract_and_trim_nils(*keys)
|
116
|
-
keys.map { |k| delete(k) }.trim!
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Imgproxy
|
2
|
-
OPTIONS_ALIASES = {
|
3
|
-
resize: :rs,
|
4
|
-
size: :s,
|
5
|
-
resizing_type: :rt,
|
6
|
-
resizing_algorithm: :ra,
|
7
|
-
width: :w,
|
8
|
-
height: :h,
|
9
|
-
enlarge: :el,
|
10
|
-
extend: :ex,
|
11
|
-
gravity: :g,
|
12
|
-
crop: :c,
|
13
|
-
padding: :pd,
|
14
|
-
trim: :t,
|
15
|
-
rotate: :rot,
|
16
|
-
quality: :q,
|
17
|
-
max_bytes: :mb,
|
18
|
-
background: :bg,
|
19
|
-
background_alpha: :bga,
|
20
|
-
adjust: :a,
|
21
|
-
brightness: :br,
|
22
|
-
contrast: :co,
|
23
|
-
saturation: :sa,
|
24
|
-
blur: :bl,
|
25
|
-
sharpen: :sh,
|
26
|
-
pixelate: :pix,
|
27
|
-
unsharpening: :ush,
|
28
|
-
watermark: :wm,
|
29
|
-
watermark_url: :wmu,
|
30
|
-
style: :st,
|
31
|
-
jpeg_options: :jpego,
|
32
|
-
png_options: :pngo,
|
33
|
-
gif_options: :gifo,
|
34
|
-
page: :pg,
|
35
|
-
video_thumbnail_second: :vts,
|
36
|
-
preset: :pr,
|
37
|
-
cachebuster: :cb,
|
38
|
-
strip_metadata: :sm,
|
39
|
-
strip_color_profile: :scp,
|
40
|
-
auto_rotate: :ar,
|
41
|
-
filename: :fn,
|
42
|
-
return_attachment: :att,
|
43
|
-
expires: :exp,
|
44
|
-
}.freeze
|
45
|
-
end
|