-
-
Save ssig33/1715541 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 ruby | |
require 'webrick' | |
require 'webrick/httpproxy' | |
require 'RMagick' | |
handler = Proc.new() { |req,res| | |
if res['content-type'] =~ /image/ | |
begin | |
img = Magick::Image.from_blob(res.body).first | |
body = img.negate.to_blob | |
res.body = body | |
rescue | |
end | |
end | |
} | |
s = WEBrick::HTTPProxyServer.new( | |
:BindAddress => '127.0.0.1', | |
:Port => 9090, | |
:ProxyContentHandler => handler | |
) | |
Signal.trap('INT') do | |
s.shutdown | |
end | |
s.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment