require 'rubygems'
require 'RMagick'
class Pdf2PngConverter
def initialize(*files)
files.each do |file|
pdf = Magick::ImageList.new(file)
filename = "#{File.join(File.dirname(file), File.basename(file, '.*'))}.png"
pdf[0].resize_to_fit(100,100).write(filename)
# gem install smusher:
# `smusher --service PunyPng #{filename}`
end
end
end
if ARGV.any?
if ARGV.size > 1
Pdf2PngConverter.new(*Dir.glob(ARGV))
else
Pdf2PngConverter.new(*Dir.glob(ARGV[0]))
end
end