我是回形针的新用户,我已成功上传图像,但我想以像素化形式保存照片,这样它就不会更明显且无法识别。
但我不知道如何用回形针实现它
class User < ActiveRecord::Base
# Paperclip
has_attached_file :photo,
:styles => {
:thumb => "100x100#",
:small => "150x150>",
:medium => "200x200" }
end
最佳答案
您可以使用“ImageMagick”对图像进行像素化..
class User < ActiveRecord::Base
has_attached_file :photo,
:styles => {
:thumb => "100x100#",
:small => "150x150>",
:medium => "200x200",
:pixlated => ['40x40#', 'png']},
:convert_options => {
:pixlated => '-scale 50% -scale 1000%'}
end
根据您的需要更改比例%。您将获得像素化图像。我希望它能帮助你。
例如:pixlated.png
原图.png
关于ruby-on-rails - 如何对图像回形针进行像素化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20425982/