Skip to content

Instantly share code, notes, and snippets.

@dennysfredericci
Created June 3, 2016 03:07
Show Gist options
  • Save dennysfredericci/43796c6f38a285998af14ed6e0993ed8 to your computer and use it in GitHub Desktop.
Save dennysfredericci/43796c6f38a285998af14ed6e0993ed8 to your computer and use it in GitHub Desktop.
Mask Image example
module ApplicationHelper
def teste
#profile_url = Net::HTTP.get_response(URI.parse("http://graph.facebook.com/#{100000335750045}/picture?type=large"))['location']
#second_image = Net::HTTP.get_response(URI.parse("https://taylorgraceauthor.files.wordpress.com/2015/11/6917465-french-flag-wallpaper.jpg"))['location']
#Deve ter transparencia
first = "#{Rails.public_path}/mask.png"
#Imagem de fundo
second = "#{Rails.public_path}/firefox.png"
first_image = MiniMagick::Image.new(first)
second_image = MiniMagick::Image.new(second)
first_image.format 'png'
second_image.format 'png'
result = first_image.composite(second_image, 'png') do |c|
c.compose "DstOver" # OverCompositeOp
#c.geometry "+200+200"
#c.alpha 'on'
#c.channel 'a'
#c.evaluate 'set', '25%'
#c.channel "A"
#c.alpha 'transparent'
end
result.format 'png'
result.write "#{Rails.public_path}/output1.png"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment