Rails 6 - Shrine - ImageProcessing - 获取原始上传文件
Rails 6 - Shrine - ImageProcessing - Get Original Uploaded file
这是我的image_uploader.rb
require "image_processing/mini_magick"
class ImageUploader < Shrine
Attacher.derivatives do |original|
magick = ImageProcessing::MiniMagick.source(original).saver(quality: 88)
# generate the thumbnails you want here
{
thumb: magick.resize_to_fill!(150, 150),
medium: magick.resize_to_fill!(500, 500),
large: magick.resize_to_limit!(800, 800),
}
end
end
问题很简单,但我找不到答案是 Shrine 文档。我怎样才能得到原始照片?在 Rails 4 中很简单,我只要求 image_url(:original)
一些技巧:
我阅读了 mini_magic 并添加了类似这样的内容
original: magick.resize_to_limit!(20000,20000),
如果不超过 20000x20000 尺寸,图像将不会更改 ...
好久没用神社了...
简单的怎么样
@image.image_url
这是我的image_uploader.rb
require "image_processing/mini_magick"
class ImageUploader < Shrine
Attacher.derivatives do |original|
magick = ImageProcessing::MiniMagick.source(original).saver(quality: 88)
# generate the thumbnails you want here
{
thumb: magick.resize_to_fill!(150, 150),
medium: magick.resize_to_fill!(500, 500),
large: magick.resize_to_limit!(800, 800),
}
end
end
问题很简单,但我找不到答案是 Shrine 文档。我怎样才能得到原始照片?在 Rails 4 中很简单,我只要求 image_url(:original)
一些技巧:
我阅读了 mini_magic 并添加了类似这样的内容
original: magick.resize_to_limit!(20000,20000),
如果不超过 20000x20000 尺寸,图像将不会更改 ...
好久没用神社了...
简单的怎么样
@image.image_url