gpt4 book ai didi

ruby-on-rails - 如何使用 imagemagick 和回形针将投影应用于缩略图?

转载 作者:数据小太阳 更新时间:2023-10-29 07:31:21 31 4
gpt4 key购买 nike

我想通过让 imagemagick 对所有缩略图应用阴影来改变回形针中缩略图的处理。我坚持的是实际的 imagemagick 命令,它可以实现这个小奇迹。我尝试过的所有操作都会返回缩放不正确的阴影,而没有原始图像。

def transformation_command
scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
trans = ""
trans << " -resize \"#{scale}\""
trans << " -crop \"#{crop}\" +repage" if crop
# Apply Drop Shadow
trans << " #{convert_options}" if convert_options?
trans
end

一个我试过...

def transformation_command
scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
trans = ""
trans << " -resize \"#{scale}\""
trans << " -crop \"#{crop}\" +repage" if crop
trans << " \( +clone -background black -shadow 60x5+10+10 \) +swap -background none -layers merge +repage"
trans << " #{convert_options}" if convert_options?
trans
end

我是 imagemagick 的新手,非常感谢任何帮助。

最佳答案

经过反复试验并埋头研究文档,我终于弄明白了。

has_attached_file :image, 
:styles => { :thumb => ["100x100#", :png] },
:convert_options => { :thumb => '\( +clone -background black -shadow 70x4+0+0 \) +swap -background none -layers merge +repage' }
  1. 确保您安装了最新版本的 ImageMagick。
  2. ["100x100#", :png] 会将图像转换为 png,以便投影是透明的。
  3. 在转换选项下,:thumb 只会将转换应用于 :thumb 样式,使用 :all 将转换应用于所有样式。
  4. 调整“70x4+0+0”以获得您想要的阴影。

关于ruby-on-rails - 如何使用 imagemagick 和回形针将投影应用于缩略图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1167983/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com