Skip to content

Instantly share code, notes, and snippets.

@sunny0425
Created November 19, 2013 03:44
Show Gist options
  • Save sunny0425/7539982 to your computer and use it in GitHub Desktop.
Save sunny0425/7539982 to your computer and use it in GitHub Desktop.
use carrirewave and mini-magick to change the png image's color
class Uploader < CarrierWave::Uploader::Base
version :full do
process resize_to_fit: [960, 640]
process :set_color
end
def set_color
color = 'gold'
# convert old.png -alpha off -fill gold -colorize 100% -alpha on new.png
manipulate! do |img|
img.combine_options do |cmd|
cmd.alpha('off')
cmd.fill(color)
cmd.colorize('100%')
cmd.alpha('on')
end
img = yield(img) if block_given?
img
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment