I am new user of paperclip and I have successfully uploaded image But I want to save photo in pixelate form so that It will not more visible and not identifiable.

But I am not sure how to implement it with paperclip

class User < ActiveRecord::Base
  # Paperclip
  has_attached_file :photo,
    :styles => {
      :thumb => "100x100#",
      :small  => "150x150>",
      :medium => "200x200" }
end

I want save photo in like that

有帮助吗?

解决方案

You can use "ImageMagick" to pixlate image..

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

change scale % as per your need. You will get pixlated image. I hope it will help you.

for examlple: pixlated.png

enter image description here

original.png

enter image description here

其他提示

You don't use paperclip for that specific functionality (Paperclip only uploads & organizes files) -- you'll need to use ImageMagick for that

I can give you more details if this is the kind of thing you're looking for?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top