Skip to content

Instantly share code, notes, and snippets.

@unreadable
Created September 7, 2017 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unreadable/73d38feb703983fdd0426340021cda73 to your computer and use it in GitHub Desktop.
Save unreadable/73d38feb703983fdd0426340021cda73 to your computer and use it in GitHub Desktop.
require "magickwand-crystal"
require "stumpy_png"
include StumpyPNG
ak = StumpyPNG.read("ak.png")
stick = StumpyPNG.read("out.png")
ibp = StumpyPNG.read("out.png")
dist_x = 252
dist_y = 7
offx1 = 550
offx2 = offx1 + dist_x # 802
offx3 = offx1 + dist_x * 2 - 73 # 981
offx4 = offx1 + dist_x * 3 - 160 #1146
offy1 = 37
offy2 = offy1 + dist_y + 2 # 46
offy3 = offy1 + dist_y + 7 # 52
stick.width.times do |x|
stick.height.times do |y|
ak[offx1 + x, offy1 + y] = RGBA.from_rgba8(*stick[x, y].to_rgba) if stick[x, y].to_rgba[3] > 200
ak[offx2 + x, offy2 + y] = RGBA.from_rgba8(*ibp[x, y].to_rgba) if ibp[x, y].to_rgba[3] > 200
ak[offx3 + x, offy3 + y] = RGBA.from_rgba8(*stick[x, y].to_rgba) if stick[x, y].to_rgba[3] > 200
ak[offx4 + x, offy3 + y] = RGBA.from_rgba8(*stick[x, y].to_rgba) if stick[x, y].to_rgba[3] > 200
end
end
StumpyPNG.write(ak, "rainbow.png")
# LibMagick.magickWandGenesis # lib init
# sticker = LibMagick.newMagickWand
# LibMagick.magickReadImage(sticker, "crown.png")
# LibMagick.magickResizeImage sticker, 180, 180, LibMagick::FilterTypes::LanczosFilter, 1
# LibMagick.magickSetImageCompressionQuality sticker, 80
# LibMagick.magickWriteImage(sticker, "out.png")
# LibMagick.destroyMagickWand sticker
# LibMagick.magickWandTerminus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment