You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-41Lines changed: 51 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,19 @@
17
17
18
18
---
19
19
20
-
**[imgproxy](https://imgproxy.net)** is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security. It is a Go application, ready to be installed and used in any Unix environment—also ready to be containerized using Docker.
20
+
[imgproxy](https://imgproxy.net) is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security. It is a Go application, ready to be installed and used in any Unix environment—also ready to be containerized using Docker.
21
21
22
22
imgproxy can be used to provide a fast and secure way to _get rid of all the image resizing code_ in your web application (like calling ImageMagick or GraphicsMagick, or using libraries), while also being able to resize everything on the fly on a separate server that only you control. imgproxy is fast, easy to use, and requires zero processing power or storage from the main application. imgproxy is indispensable when handling image resizing of epic proportions, especially when original images are coming from a remote source.
23
23
24
24
[imgproxy.rb](https://github.com/imgproxy/imgproxy.rb) is a framework-agnostic Ruby Gem for imgproxy that includes proper support for Ruby on Rails' most popular image attachment options: [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) and [Shrine](https://github.com/shrinerb/shrine).
25
25
26
-
**NOTE:** this readme shows documentation for 2.x version. For version 1.x see the [v1.2.0](https://github.com/imgproxy/imgproxy.rb/tree/v1.2.0) tag. See [2.0-Upgrade.md](2.0-Upgrade.md) for the upgrade guide.
26
+
> [!IMPORTANT]
27
+
> This readme shows documentation for version 3.x.
28
+
>
29
+
> * For version 2.x see the [v2.1.0](https://github.com/imgproxy/imgproxy.rb/tree/v2.1.0) tag
30
+
> * For version 1.x see the [v1.2.0](https://github.com/imgproxy/imgproxy.rb/tree/v1.2.0) tag
31
+
>
32
+
> See [Upgrading imgproxy.rb](UPGRADE.md) for the upgrade guide.
27
33
28
34
## Installation
29
35
@@ -35,15 +41,15 @@ gem "imgproxy"
35
41
36
42
or install system-wide:
37
43
38
-
```
44
+
```bash
39
45
gem install imgproxy
40
46
```
41
47
42
48
## Configuration
43
49
44
50
imgproxy.rb uses [anyway_config](https://github.com/palkan/anyway_config) to load configuration, so you can configure it in different ways.
45
51
46
-
-With a separate config file:
52
+
With a separate config file:
47
53
48
54
```yaml
49
55
# <Rails root>/config/imgproxy.yml
@@ -57,7 +63,7 @@ production: ...
57
63
test: ...
58
64
```
59
65
60
-
- With a `secrets.yml` entry for imgproxy:
66
+
With a `secrets.yml` entry for imgproxy:
61
67
62
68
```yaml
63
69
# secrets.yml
@@ -72,7 +78,7 @@ production:
72
78
...
73
79
```
74
80
75
-
- With environment variables:
81
+
With environment variables:
76
82
77
83
```bash
78
84
IMGPROXY_ENDPOINT="http://imgproxy.example.com" \
@@ -81,7 +87,7 @@ IMGPROXY_SALT="your_salt" \
81
87
rails s
82
88
```
83
89
84
-
- ...or right in your application code:
90
+
...or right in your application code:
85
91
86
92
```ruby
87
93
# config/initializers/imgproxy.rb
@@ -97,22 +103,22 @@ end
97
103
98
104
### Configuration options
99
105
100
-
- **endpoint** (`IMGPROXY_ENDPOINT`) - Full URL to your imgproxy instance. Default: `nil`.
- **signature_size** (`IMGPROXY_SIGNATURE_SIZE`) - Signature size. See [URL signature](https://docs.imgproxy.net/configuration/options#url-signature) section of imgproxy docs. Default: 32.
106
-
- **use_short_options** (`IMGPROXY_USE_SHORT_OPTIONS`) - Use short processing options names (`rs` for `resize`, `g` for `gravity`, etc). Default: true.
- **always_escape_plain_urls** (`IMGPROXY_ALWAYS_ESCAPE_PLAIN_URLS`) - Always escape plain source URLs even when ones don't need to be escaped. Default: false.
- **use_s3_urls** (`IMGPROXY_USE_S3_URLS`) - Use `s3://...` source URLs for Active Storage and Shrine attachments stored in Amazon S3. Default: false.
113
-
- **use_gcs_urls** (`IMGPROXY_USE_GCS_URLS`) - Use `gs://...` source URLs for Active Storage and Shrine attachments stored in Google Cloud Storage. Default: false.
* `always_escape_plain_urls` (`IMGPROXY_ALWAYS_ESCAPE_PLAIN_URLS`) - Always escape plain source URLs even when ones don't need to be escaped. Default: false.
* `use_s3_urls` (`IMGPROXY_USE_S3_URLS`) - Use `s3://...` source URLs for Active Storage and Shrine attachments stored in Amazon S3. Default: false.
119
+
* `use_gcs_urls` (`IMGPROXY_USE_GCS_URLS`) - Use `gs://...` source URLs for Active Storage and Shrine attachments stored in Google Cloud Storage. Default: false.
* `shrine_host` (`IMGPROXY_SHRINE_HOST`) - Shrine host for locally stored files.
116
122
117
123
## Usage
118
124
@@ -150,7 +156,8 @@ If you have configured both your imgproxy server and Active Storage to work with
150
156
151
157
You can also enable `gs://...` URLs usage for the files stored in Google Cloud Storage with `use_gcs_urls` and `gcs_bucket` config options (or `IMGPROXY_USE_GCS_URLS` and `IMGPROXY_GCS_BUCKET` env variables).
152
158
153
-
**NOTE** that you need to explicitly provide GCS bucket name since Active Storage "hides" the GCS config.
159
+
> [!IMPORTANT]
160
+
> You need to explicitly provide GCS bucket name since Active Storage "hides" the GCS config.
This method will return a URL to the JSON with the requested info about your user's avatar.
180
187
181
-
**NOTE:** If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this, use `shrine_host` config.
182
-
183
-
Alternatively, you can launch your imgproxy server with the `IMGPROXY_BASE_URL` setting:
> If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this, use `shrine_host` config.
190
+
>
191
+
> Alternatively, you can launch your imgproxy server with the `IMGPROXY_BASE_URL` setting:
-`base64_encode_url`— per-call redefinition of `base64_encode_urls` config.
247
-
-`escape_plain_url`— per-call redefinition of `always_escape_plain_urls` config.
248
-
-`use_short_options`— per-call redefinition of `use_short_options` config.
249
-
-`encrypt_source_url`- _(pro)_ per-call redefinition of `always_encrypt_source_urls` config.
250
-
-`source_url_encryption_iv`- _(pro)_ an initialization vector (IV) to be used for the source URL encryption if encryption is needed. If not specified, a random IV is used.
254
+
* `base64_encode_url` — per-call redefinition of `base64_encode_urls` config.
255
+
* `escape_plain_url` — per-call redefinition of `always_escape_plain_urls` config.
256
+
* `use_short_options` — per-call redefinition of `use_short_options` config.
257
+
* `encrypt_source_url` - _(pro)_ per-call redefinition of `always_encrypt_source_urls` config.
258
+
* `source_url_encryption_iv` - _(pro)_ an initialization vector (IV) to be used for the source URL encryption if encryption is needed. If not specified, a random IV is used.
251
259
252
260
### Processing options
253
261
@@ -331,7 +339,7 @@ Imgproxy.url_for(
331
339
332
340
### Base64 processing options arguments
333
341
334
-
Some of the processing options like `watermark_url` or `style` require their arguments to be base64-encoded. Good news is that imgproxy gem will encode them for you:
342
+
Some of the processing options like `watermark_url` or `style` require their arguments to be base64-encoded. Good news is that imgproxy.rb will encode them for you:
335
343
336
344
```ruby
337
345
Imgproxy.url_for(
@@ -346,6 +354,9 @@ Imgproxy.url_for(
346
354
347
355
By default, `Imgproxy.url_for` accepts only `String` and `URI` as the source URL, but you can extend that behavior by using URL adapters.
348
356
357
+
> [!TIP]
358
+
> imgproxy.rb provides built-in adapters for Active Storage and Shrine that are automatically added when Active Storage or Shrine support is enabled.
359
+
349
360
URL adapter is a simple class that implements `applicable?` and `url` methods. See the example below:
350
361
351
362
```ruby
@@ -369,11 +380,10 @@ Imgproxy.configure do |config|
369
380
end
370
381
```
371
382
372
-
**NOTE:** imgproxy.rb provides built-in adapters for Active Storage and Shrine that are automatically added when Active Storage or Shrine support is enabled.
373
-
374
-
**NOTE:**`Imgproxy` will use the first applicable URL adapter. If you need to add your adapter to the beginning of the list, use the `prepend` method instead of `add`.
383
+
> [!NOTE]
384
+
> `Imgproxy` will use the first applicable URL adapter. If you need to add your adapter to the beginning of the list, use the `prepend` method instead of `add`.
375
385
376
-
## Custom services
386
+
## Extra services
377
387
378
388
If you use more than one instance of imgproxy and they have different endpoints and key/salt configurations you can specify them in `services` option.
0 commit comments