Skip to content

Commit 1b3f4a2

Browse files
committed
Reflow Active Storage transforms section [ci-skip]
Both "optional arguments" and "migrating processors" seem too specific for where they were previously located within the section. Both ideas are more complicated/processor specific, but are located very early on when the ideas should be more simple/introductory. This commit reorders the paragraphs a bit to improve the section's flow. Now, the most basic examples are presented first, then the idea of processors and what they have in common, and finally the more advanced options and how the processors differ.
1 parent 8887b65 commit 1b3f4a2

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

guides/source/active_storage_overview.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,6 @@ location.
961961
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100]) %>
962962
```
963963

964-
Some transformations accept optional arguments. Pass any additional arguments to the transformation function as key: value pairs inside a hash:
965-
966-
```erb
967-
<%= image_tag user.avatar.variant(resize_to_fill: [100, 100, { crop: :centre }]) %>
968-
```
969-
970964
If a variant is requested, Active Storage will automatically apply
971965
transformations depending on the image's format:
972966

@@ -980,18 +974,6 @@ Active Storage can use either [Vips][] or MiniMagick as the variant processor.
980974
The default depends on your `config.load_defaults` target version, and the
981975
processor can be changed by setting [`config.active_storage.variant_processor`][].
982976

983-
The two processors are not fully compatible, so when migrating an existing application
984-
between MiniMagick and Vips, some changes have to be made if using options that are format
985-
specific:
986-
987-
```erb
988-
<!-- MiniMagick -->
989-
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100], format: :jpeg, sampling_factor: "4:2:0", strip: true, interlace: "JPEG", colorspace: "sRGB", quality: 80) %>
990-
991-
<!-- Vips -->
992-
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100], format: :jpeg, saver: { subsample_mode: "on", strip: true, interlace: true, quality: 80 }) %>
993-
```
994-
995977
The parameters available are defined by the [`image_processing`][] gem and depend on the
996978
variant processor that you are using, but both support the following parameters:
997979

@@ -1004,8 +986,30 @@ variant processor that you are using, but both support the following parameters:
1004986
| `crop` | `crop: [20, 50, 300, 300]` | Extracts an area from an image. The first two arguments are the left and top edges of area to extract, while the last two arguments are the width and height of the area to extract. |
1005987
| `rotate` | `rotate: 90` | Rotates the image by the specified angle. |
1006988

1007-
[`image_processing`][] has more options available (such as `saver` which allows image compression to be configured) in it's own documentation for the [Vips](https://github.com/janko/image_processing/blob/master/doc/vips.md) and [MiniMagick](https://github.com/janko/image_processing/blob/master/doc/minimagick.md) processors.
989+
[`image_processing`][] has all parameters available in it's own documentation
990+
for both the
991+
[Vips](https://github.com/janko/image_processing/blob/master/doc/vips.md) and
992+
[MiniMagick](https://github.com/janko/image_processing/blob/master/doc/minimagick.md)
993+
processors.
1008994

995+
Some parameters, including those listed above, accept additional processor
996+
specific options which can be passed as `key: value` pairs inside a hash:
997+
998+
```erb
999+
<!-- Vips supports configuring `crop` for many of its transformations -->
1000+
<%= image_tag user.avatar.variant(resize_to_fill: [100, 100, { crop: :centre }]) %>
1001+
```
1002+
1003+
If migrating an existing application between MiniMagick and Vips, processor
1004+
specific options will need to be updated:
1005+
1006+
```erb
1007+
<!-- MiniMagick -->
1008+
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100], format: :jpeg, sampling_factor: "4:2:0", strip: true, interlace: "JPEG", colorspace: "sRGB", quality: 80) %>
1009+
1010+
<!-- Vips -->
1011+
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100], format: :jpeg, saver: { subsample_mode: "on", strip: true, interlace: true, quality: 80 }) %>
1012+
```
10091013

10101014
[`config.active_storage.variable_content_types`]: configuring.html#config-active-storage-variable-content-types
10111015
[`config.active_storage.variant_processor`]: configuring.html#config-active-storage-variant-processor

0 commit comments

Comments
 (0)