Skip to content

Instantly share code, notes, and snippets.

@ferclaverino
Created November 4, 2012 18:02
Show Gist options
  • Save ferclaverino/4012799 to your computer and use it in GitHub Desktop.
Save ferclaverino/4012799 to your computer and use it in GitHub Desktop.
Image manipulation in shoes
Shoes.setup do
gem "chunky_png"
end
require "chunky_png"
Shoes.app(:title => "Fotoyop", :width => 800, :height => 600, :resize => true) do
stack do
title("fotoyop")
button("cargar imagen") do
@imagen = ask_open_file
image(@imagen)
end
button("cargar sello") do
@sello = ask_open_file
image(@sello)
end
button("sellar") do
avatar = ChunkyPNG::Image.from_file(@imagen)
badge = ChunkyPNG::Image.from_file(@sello)
avatar.compose!(badge, 10, 10)
avatar.save("composited.png") # Force the fast saving routine.
image("composited.png")
end
button("rotar") do
image = ChunkyPNG::Image.from_file(@imagen)
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
new_image = image.flip_horizontally.rotate_right
new_image.save("rotada.png")
image("rotada.png")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment