aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-04-23 16:01:16 -0500
committerGitHub <noreply@github.com>2018-04-23 16:01:16 -0500
commitef5902a2f195c2be5a4e9ad0f31003774a93aa1c (patch)
treed9366b40aa381688eb828d54628d5712bc5a1a60 /guides
parente970d15211a8efd7349ff0e90d44d887b85793c2 (diff)
parentf2e2cef15bdb31353aee2254ca2ab378979cc24a (diff)
downloadrails-ef5902a2f195c2be5a4e9ad0f31003774a93aa1c.tar.gz
rails-ef5902a2f195c2be5a4e9ad0f31003774a93aa1c.tar.bz2
rails-ef5902a2f195c2be5a4e9ad0f31003774a93aa1c.zip
Merge pull request #32471 from janko-m/use-image_processing-gem
Use ImageProcessing gem for ActiveStorage variants
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_storage_overview.md23
-rw-r--r--guides/source/configuring.md2
2 files changed, 18 insertions, 7 deletions
diff --git a/guides/source/active_storage_overview.md b/guides/source/active_storage_overview.md
index d67f65e88a..4a915b1083 100644
--- a/guides/source/active_storage_overview.md
+++ b/guides/source/active_storage_overview.md
@@ -337,14 +337,15 @@ rails_blob_path(user.avatar, disposition: "attachment")
Transforming Images
-------------------
-To create variation of the image, call `variant` on the Blob.
-You can pass any [MiniMagick](https://github.com/minimagick/minimagick)
-supported transformation to the method.
+To create variation of the image, call `variant` on the Blob. You can pass
+any transformation to the method supported by the processor. The default
+processor is [MiniMagick](https://github.com/minimagick/minimagick), but you
+can also use [Vips](http://www.rubydoc.info/gems/ruby-vips/Vips/Image).
-To enable variants, add `mini_magick` to your `Gemfile`:
+To enable variants, add the `image_processing` gem to your `Gemfile`:
```ruby
-gem 'mini_magick'
+gem 'image_processing', '~> 1.2'
```
When the browser hits the variant URL, Active Storage will lazy transform the
@@ -352,7 +353,15 @@ original blob into the format you specified and redirect to its new service
location.
```erb
-<%= image_tag user.avatar.variant(resize: "100x100") %>
+<%= image_tag user.avatar.variant(resize_to_fit: [100, 100]) %>
+```
+
+To switch to the Vips processor, you would add the following to
+`config/application.rb`:
+
+```ruby
+# Use Vips for processing variants.
+config.active_storage.variant_processor = :vips
```
Previewing Files
@@ -366,7 +375,7 @@ the box, Active Storage supports previewing videos and PDF documents.
<ul>
<% @message.files.each do |file| %>
<li>
- <%= image_tag file.preview(resize: "100x100>") %>
+ <%= image_tag file.preview(resize_to_limit: [100, 100]) %>
</li>
<% end %>
</ul>
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index 7d5ca4b8a7..c98e9b719c 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -778,6 +778,8 @@ normal Rails server.
`config.active_storage` provides the following configuration options:
+* `config.active_storage.variant_processor` accepts a symbol `:mini_magick` or `:vips`, specifying whether variant transformations will be performed with MiniMagick or ruby-vips. The default is `:mini_magick`.
+
* `config.active_storage.analyzers` accepts an array of classes indicating the analyzers available for Active Storage blobs. The default is `[ActiveStorage::Analyzer::ImageAnalyzer, ActiveStorage::Analyzer::VideoAnalyzer]`. The former can extract width and height of an image blob; the latter can extract width, height, duration, angle, and aspect ratio of a video blob.
* `config.active_storage.previewers` accepts an array of classes indicating the image previewers available in Active Storage blobs. The default is `[ActiveStorage::Previewer::PDFPreviewer, ActiveStorage::Previewer::VideoPreviewer]`. The former can generate a thumbnail from the first page of a PDF blob; the latter from the relevant frame of a video blob.