imgproxy 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +8 -0
  3. data/CHANGELOG.md +74 -0
  4. data/README.md +176 -133
  5. data/UPGRADE.md +136 -0
  6. data/docs/info_options.md +223 -0
  7. data/docs/processing_options.md +724 -0
  8. data/docs/yard/fix_pictures.rb +25 -0
  9. data/docs/yard/github_alerts.rb +16 -0
  10. data/docs/yard/relative_markdown_links.rb +31 -0
  11. data/lib/imgproxy/config.rb +96 -41
  12. data/lib/imgproxy/extensions/active_storage.rb +6 -4
  13. data/lib/imgproxy/extensions/shrine.rb +6 -4
  14. data/lib/imgproxy/option_aliases/info.rb +33 -0
  15. data/lib/imgproxy/option_aliases/processing.rb +74 -0
  16. data/lib/imgproxy/options_builders/base.rb +54 -0
  17. data/lib/imgproxy/options_builders/info.rb +52 -0
  18. data/lib/imgproxy/options_builders/processing.rb +150 -0
  19. data/lib/imgproxy/options_casters/adjust.rb +3 -1
  20. data/lib/imgproxy/options_casters/alpha.rb +27 -0
  21. data/lib/imgproxy/options_casters/array.rb +3 -1
  22. data/lib/imgproxy/options_casters/autoquality.rb +28 -0
  23. data/lib/imgproxy/options_casters/average.rb +27 -0
  24. data/lib/imgproxy/options_casters/background.rb +27 -0
  25. data/lib/imgproxy/options_casters/base64.rb +2 -0
  26. data/lib/imgproxy/options_casters/blur_detections.rb +28 -0
  27. data/lib/imgproxy/options_casters/blurhash.rb +21 -0
  28. data/lib/imgproxy/options_casters/bool.rb +3 -1
  29. data/lib/imgproxy/options_casters/crop.rb +3 -1
  30. data/lib/imgproxy/options_casters/dominant_colors.rb +27 -0
  31. data/lib/imgproxy/options_casters/draw_detections.rb +28 -0
  32. data/lib/imgproxy/options_casters/extend.rb +3 -1
  33. data/lib/imgproxy/options_casters/filename.rb +31 -0
  34. data/lib/imgproxy/options_casters/float.rb +4 -2
  35. data/lib/imgproxy/options_casters/format_quality.rb +19 -0
  36. data/lib/imgproxy/options_casters/gradient.rb +31 -0
  37. data/lib/imgproxy/options_casters/gravity.rb +20 -6
  38. data/lib/imgproxy/options_casters/group.rb +2 -0
  39. data/lib/imgproxy/options_casters/hashsum.rb +24 -0
  40. data/lib/imgproxy/options_casters/integer.rb +2 -0
  41. data/lib/imgproxy/options_casters/jpeg_options.rb +3 -1
  42. data/lib/imgproxy/options_casters/padding.rb +41 -0
  43. data/lib/imgproxy/options_casters/png_options.rb +3 -1
  44. data/lib/imgproxy/options_casters/resize.rb +3 -1
  45. data/lib/imgproxy/options_casters/size.rb +3 -1
  46. data/lib/imgproxy/options_casters/string.rb +2 -0
  47. data/lib/imgproxy/options_casters/trim.rb +3 -1
  48. data/lib/imgproxy/options_casters/unsharp_masking.rb +25 -0
  49. data/lib/imgproxy/options_casters/video_thumbnail_tile.rb +34 -0
  50. data/lib/imgproxy/options_casters/watermark.rb +5 -4
  51. data/lib/imgproxy/options_casters/watermark_size.rb +21 -0
  52. data/lib/imgproxy/options_casters/{gif_options.rb → webp_options.rb} +6 -5
  53. data/lib/imgproxy/options_casters/zoom.rb +27 -0
  54. data/lib/imgproxy/service_config.rb +111 -0
  55. data/lib/imgproxy/trim_array.rb +2 -0
  56. data/lib/imgproxy/url_adapters/active_storage.rb +15 -3
  57. data/lib/imgproxy/url_adapters/shrine.rb +9 -3
  58. data/lib/imgproxy/url_adapters.rb +3 -0
  59. data/lib/imgproxy/url_builders/base.rb +184 -0
  60. data/lib/imgproxy/url_builders/info.rb +44 -0
  61. data/lib/imgproxy/url_builders/processing.rb +59 -0
  62. data/lib/imgproxy/version.rb +3 -1
  63. data/lib/imgproxy.rb +19 -55
  64. data/logo/logo-dark.svg +22 -0
  65. data/logo/logo-light.svg +31 -0
  66. metadata +74 -35
  67. data/lib/imgproxy/builder.rb +0 -140
  68. data/lib/imgproxy/options.rb +0 -115
  69. data/lib/imgproxy/options_aliases.rb +0 -43
data/UPGRADE.md ADDED
@@ -0,0 +1,136 @@
1
+ <!--
2
+ # @title Upgrading imgproxy.rb
3
+ -->
4
+
5
+ # Upgrading imgproxy.rb
6
+
7
+ ## Upgrading 2.x to 3.x
8
+
9
+ Version 3.0 brings a single breaking change and a single deprecation:
10
+
11
+ * `Imgproxy::Builder` class was replaced with `Imgproxy::UrlBuilders::Processing`. If you don't use URL builders directly, you are not affected by this change. Otherwise, just replace the old class with the new one:
12
+
13
+ **Was:**
14
+
15
+ ```ruby
16
+ builder = Imgproxy::Builder.new(
17
+ width: 500,
18
+ height: 400,
19
+ resizing_type: :fill,
20
+ sharpen: 0.5
21
+ )
22
+ ```
23
+
24
+ **Becomes:**
25
+
26
+ ```ruby
27
+ builder = Imgproxy::UrlBuilders::Processing.new(
28
+ width: 500,
29
+ height: 400,
30
+ resizing_type: :fill,
31
+ sharpen: 0.5
32
+ )
33
+ ```
34
+
35
+ * The `unsharpening` processing option was deprecated, use the `unsharp_masking` option.
36
+
37
+ ## Upgrading 1.x to 2.x
38
+
39
+ Version 2.0 brings several breaking changes. Here are some things you need to know to safely upgrade from version 1.x to 2.0.
40
+
41
+ * If you use `key` and `salt` config options to provide raw (not hex-encoded) key/salt pair, use `raw_key` and `raw_salt` instead.
42
+
43
+ **Was:**
44
+
45
+ ```ruby
46
+ Imgproxy.configure do |config|
47
+ config.key = "your_raw_key"
48
+ config.salt = "your_raw_salt"
49
+ end
50
+ ```
51
+
52
+ **Becomes:**
53
+
54
+ ```ruby
55
+ Imgproxy.configure do |config|
56
+ config.raw_key = "your_raw_key"
57
+ config.raw_salt = "your_raw_salt"
58
+ end
59
+ ```
60
+
61
+ * If you use `hex_key` and `hex_salt` config options to provide hex-encoded key/salt pair, use `key` and `salt` instead.
62
+
63
+ **Was:**
64
+
65
+ ```ruby
66
+ Imgproxy.configure do |config|
67
+ config.hex_key = "your_key"
68
+ config.hex_salt = "your_salt"
69
+ end
70
+ ```
71
+
72
+ **Becomes:**
73
+
74
+ ```ruby
75
+ Imgproxy.configure do |config|
76
+ config.key = "your_key"
77
+ config.salt = "your_salt"
78
+ end
79
+ ```
80
+
81
+ * If you use complex processing options with multiple arguments like `crop`, `gravity`, `watermark`, etc, rewrite their usage according to the [Complex processing options](README.md#complex-processing-options) chapter in the gem's documentation.
82
+
83
+ **Was:**
84
+
85
+ ```ruby
86
+ Imgproxy.url_for(
87
+ image_url,
88
+ crop_width: 500,
89
+ crop_height: 600,
90
+ crop_gravity: :nowe,
91
+ watermark_opacity: 0.5,
92
+ watermark_scale: 0.3
93
+ )
94
+ ```
95
+
96
+ **Becomes:**
97
+
98
+ ```ruby
99
+ Imgproxy.url_for(
100
+ image_url,
101
+ crop: { width: 500, height: 600, gravity: { type: :nowe } },
102
+ watermark: { opacity: 0.5, scale: 0.3 }
103
+ )
104
+ ```
105
+
106
+ * If you use integration with Active Storage, put `gem "imgproxy"` after `gem "rails"` in your `Gemfile` and remove `Imgproxy.extend_active_storage!` from your initializer. Active Storage support is enabled automatically since the version 2.0.
107
+
108
+ * If you use integration with Shrine, put `gem "imgproxy"` after `gem "shrine"` in your `Gemfile` and remove `Imgproxy.extend_shrine!` from your initializer. Shrine support is enabled automatically since the version 2.0.
109
+
110
+ * If you use additional options for the Active Storage or Shrine integrations, move them to centralized config under `Imgproxy.configure`.
111
+
112
+ **Was:**
113
+
114
+ ```ruby
115
+ Imgproxy.extend_active_storage!(
116
+ use_s3: true,
117
+ use_gcs: true,
118
+ gcs_bucket: "my_bucket"
119
+ )
120
+
121
+ Imgproxy.extend_shrine!(
122
+ host: "http://your-host.test",
123
+ use_s3: true
124
+ )
125
+ ```
126
+
127
+ **Becomes:**
128
+
129
+ ```ruby
130
+ Imgproxy.configure do |config|
131
+ config.use_s3_urls = true
132
+ config.use_gcs_urls = true
133
+ config.gcs_bucket = "my_bucket"
134
+ config.shrine_host = "http://your-host.test"
135
+ end
136
+ ```
@@ -0,0 +1,223 @@
1
+ <!--
2
+ # @title Supported info options
3
+ -->
4
+ # Supported info options
5
+
6
+ ### [size](https://docs.imgproxy.net/usage/getting_info#size)
7
+
8
+ ```ruby
9
+ {
10
+ size: true || false
11
+ }
12
+ ```
13
+
14
+ ### [format](https://docs.imgproxy.net/usage/getting_info#format)
15
+
16
+ ```ruby
17
+ {
18
+ format: true || false
19
+ }
20
+ ```
21
+
22
+ ### [dimensions](https://docs.imgproxy.net/usage/getting_info#dimensions)
23
+
24
+ ```ruby
25
+ {
26
+ dimensions: true || false
27
+ }
28
+ ```
29
+
30
+ ### [video_meta](https://docs.imgproxy.net/usage/getting_info#video-meta)
31
+
32
+ ```ruby
33
+ {
34
+ video_meta: true || false
35
+ }
36
+ ```
37
+
38
+ ### [detect_objects](https://docs.imgproxy.net/usage/getting_info#detect-objects)
39
+
40
+ ```ruby
41
+ {
42
+ detect_objects: true || false
43
+ }
44
+ ```
45
+
46
+ ### [colorspace](https://docs.imgproxy.net/usage/getting_info#colorspace)
47
+
48
+ ```ruby
49
+ {
50
+ colorspace: true || false
51
+ }
52
+ ```
53
+
54
+ ### [bands](https://docs.imgproxy.net/usage/getting_info#bands)
55
+
56
+ ```ruby
57
+ {
58
+ bands: true || false
59
+ }
60
+ ```
61
+
62
+ ### [sample_format](https://docs.imgproxy.net/usage/getting_info#sample-format)
63
+
64
+ ```ruby
65
+ {
66
+ sample_format: true || false
67
+ }
68
+ ```
69
+
70
+ ### [pages_number](https://docs.imgproxy.net/usage/getting_info#pages-number)
71
+
72
+ ```ruby
73
+ {
74
+ pages_number: true || false
75
+ }
76
+ ```
77
+
78
+ ### [alpha](https://docs.imgproxy.net/usage/getting_info#alpha)
79
+
80
+ ```ruby
81
+ {
82
+ alpha: {
83
+ alpha: true || false,
84
+ check_transparency: true || false,
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### [crop](https://docs.imgproxy.net/usage/getting_info#crop)
90
+
91
+ ```ruby
92
+ {
93
+ crop: {
94
+ width: Float,
95
+ height: Float,
96
+ gravity: gravity, # See the 'gravity' processing option
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### [palette](https://docs.imgproxy.net/usage/getting_info#palette)
102
+
103
+ ```ruby
104
+ {
105
+ palette: Integer
106
+ }
107
+ ```
108
+
109
+ ### [average](https://docs.imgproxy.net/usage/getting_info#average)
110
+
111
+ ```ruby
112
+ {
113
+ average: {
114
+ average: true || false,
115
+ ignore_transparent: true || false,
116
+ }
117
+ }
118
+ ```
119
+
120
+ ### [dominant_colors](https://docs.imgproxy.net/usage/getting_info#dominant_colors)
121
+
122
+ ```ruby
123
+ {
124
+ dominant_colors: {
125
+ dominant_colors: true || false,
126
+ build_missed: true || false,
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### [blurhash](https://docs.imgproxy.net/usage/getting_info#blurhash)
132
+
133
+ ```ruby
134
+ {
135
+ blurhash: {
136
+ x_components: Integer,
137
+ y_components: Integer,
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### [calc_hashsum](https://docs.imgproxy.net/usage/getting_info#calc_hashsum)
143
+
144
+ ```ruby
145
+ {
146
+ calc_hashsum: Array[String || Symbol]
147
+ }
148
+ ```
149
+
150
+ ### [page](https://docs.imgproxy.net/usage/getting_info#page)
151
+
152
+ ```ruby
153
+ {
154
+ page: Integer
155
+ }
156
+ ```
157
+
158
+ ### [video_thumbnail_second](https://docs.imgproxy.net/usage/getting_info#video_thumbnail_second)
159
+
160
+ ```ruby
161
+ {
162
+ video_thumbnail_second: Float
163
+ }
164
+ ```
165
+
166
+ ### [video_thumbnail_keyframes](https://docs.imgproxy.net/usage/getting_info#video_thumbnail_keyframes)
167
+
168
+ ```ruby
169
+ {
170
+ video_thumbnail_keyframes: true || false
171
+ }
172
+ ```
173
+
174
+ ### [cachebuster](https://docs.imgproxy.net/usage/getting_info#cachebuster)
175
+
176
+ ```ruby
177
+ {
178
+ cachebuster: String || Symbol
179
+ }
180
+ ```
181
+
182
+ ### [expires](https://docs.imgproxy.net/usage/getting_info#expires)
183
+
184
+ ```ruby
185
+ {
186
+ expires: Integer || Time,
187
+ }
188
+ ```
189
+
190
+ ### [preset](https://docs.imgproxy.net/usage/getting_info#preset)
191
+
192
+ ```ruby
193
+ {
194
+ preset: Array[String || Symbol]
195
+ }
196
+ ```
197
+
198
+ ### [hashsum](https://docs.imgproxy.net/usage/getting_info#hashsum)
199
+
200
+ ```ruby
201
+ {
202
+ hashsum: {
203
+ hashsum_type: Array[String || Symbol]
204
+ hashsum: String,
205
+ }
206
+ }
207
+ ```
208
+
209
+ ### [max_src_resolution](https://docs.imgproxy.net/usage/getting_info#max_src_resolution)
210
+
211
+ ```ruby
212
+ {
213
+ max_src_resolution: Float
214
+ }
215
+ ```
216
+
217
+ ### [max_src_file_size](https://docs.imgproxy.net/usage/getting_info#max_src_file_size)
218
+
219
+ ```ruby
220
+ {
221
+ max_src_file_size: Integer
222
+ }
223
+ ```