Active Storage Transformers Transformer
Transformer
會對圖片套用一組轉換。
Active Storage 包含以下具體子類別
-
ActiveStorage::Transformers::ImageProcessingTransformer
:由 ImageProcessing 支援,這是 MiniMagick 和 ruby-vips 的共通介面
方法
屬性
[R] | transformations |
類別公共方法
new(transformations) 連結
來源: 顯示 | 在 GitHub 上
# File activestorage/lib/active_storage/transformers/transformer.rb, line 16 def initialize(transformations) @transformations = transformations end
執行個體公共方法
transform(file, format:) 連結
在 file
中的來源圖片套用轉換,產生指定 format
的目標圖片。讓出包含目標圖片的開啟暫存檔。在讓出給指定區塊後關閉和取消連結輸出暫存檔。傳回區塊的結果。
來源: 顯示 | 在 GitHub 上
# File activestorage/lib/active_storage/transformers/transformer.rb, line 23 def transform(file, format:) output = process(file, format: format) begin yield output ensure output.close! end end
執行個體私人方法
process(file, format:) 連結
傳回包含以指定 format
轉換的圖片的開啟暫存檔。所有子類別都會實作這個方法。
來源: 顯示 | 在 GitHub 上
# File activestorage/lib/active_storage/transformers/transformer.rb, line 36 def process(file, format:) # :doc: raise NotImplementedError end