Created
September 7, 2010 17:54
-
-
Save c18t/568739 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env jruby | |
# | |
# require http://github.com/shokai/glitchicon | |
require File.dirname(__FILE__)+'/glitch' | |
require 'java' | |
import 'java.lang.System' | |
import 'javax.imageio.ImageIO' | |
import 'java.awt.image.BufferedImage' | |
g = Glitch.new | |
if ARGV.size < 2 | |
STDERR.puts 'require : input and output image' | |
STDERR.puts 'jruby glitchicon.rb input.jpg output.jpg' | |
g.plugins.each_index{|i| | |
STDERR.puts ' '+i.to_s+': '+g.plugins[i][1] | |
} | |
exit 1 | |
end | |
img_in = ImageIO.read(java.io.File.new(ARGV.shift)) | |
out_name = ARGV.shift | |
puts "#{img_in.width}:#{img_in.height}" | |
img = BufferedImage.new(img_in.width, img_in.height, img_in.type); | |
img.graphics.drawImage(img_in, 0, 0, nil) | |
ARGV.each{|no| | |
plugin = g.plugins[no.to_i] | |
img, plugin = g.glitch(img, plugin) | |
puts plugin[1] | |
} | |
ImageIO.write(img, out_name.split(/\./).last, java.io.File.new(out_name)) | |
puts out_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment