Created
May 27, 2017 02:31
-
-
Save hyuki0000/e745df346aeafe70488e57c7ae2e1b16 to your computer and use it in GitHub Desktop.
transpoint - Twitterにpng画像をアップロードするときにjpeg圧縮が掛からないように右下隅の1ピクセルを透明にする
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 | |
# http://www.mk-mode.com/octopress/2013/08/28/ruby-write-character-by-rmagick/ | |
# http://www.gesource.jp/weblog/?p=194 | |
# transpoint - Twitterにpng画像をアップロードするときにjpeg圧縮が掛からないように右下隅の1ピクセルを透明にする | |
require 'fileutils' | |
require 'RMagick' | |
def transpoint(image_filename) | |
image = Magick::ImageList.new(image_filename) | |
image.pixel_color(image.columns - 1, image.rows - 1, 'transparent'); | |
image.write(image_filename) | |
end | |
if ARGV.length != 1 | |
abort("Usage: transpoint filename.png") | |
end | |
filename = ARGV[0] | |
transpoint(filename) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment