Skip to content

Instantly share code, notes, and snippets.

@k0kubun
Last active December 19, 2015 07:18
Show Gist options
  • Save k0kubun/5917387 to your computer and use it in GitHub Desktop.
Save k0kubun/5917387 to your computer and use it in GitHub Desktop.
require 'RMagick'
bmp_file_name = ARGV[0]
image = Magick::Image.read(bmp_file_name).first
top_left_pixel = image.pixel_color(0, 0)
top_left_color = top_left_pixel.to_color(Magick::AllCompliance, false, 8, true)
png_file_name = bmp_file_name.gsub(/bmp$/, 'png')
`convert -transparent "#{top_left_color}" #{bmp_file_name} #{png_file_name}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment