Created
November 19, 2013 03:44
-
-
Save sunny0425/7539982 to your computer and use it in GitHub Desktop.
use carrirewave and mini-magick to change the png image's color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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