Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Forked from kkosuge/glitch.rb
Created October 9, 2011 02:16
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 ToQoz/1273196 to your computer and use it in GitHub Desktop.
Save ToQoz/1273196 to your computer and use it in GitHub Desktop.
jpegからイケメン画像たくさん生成するやつ(Macじゃなくても動く気がする
require 'base64'
path = ARGV.shift
if File.exists?(path) && path.match(/^(.+)\.(.+)$/)
files = []
filename = $1
ext = $2
10.times do |i|
10.times do |j|
File.open(path,'r') do |f|
File.open("#{filename}#{i}#{j}.#{ext}",'w') do |img|
img.write Base64.decode64(Base64.encode64(f.read).gsub(i.to_s,j.to_s))
end
files << output = "#{filename}#{i}#{j}.#{ext}"
end
end
end
# `open -a preview #{files.join(" ")}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment