2010-01-07 03:56:52 +00:00
|
|
|
require File.dirname(__FILE__) + '/OutputFilter.rb'
|
2010-01-10 22:12:23 +00:00
|
|
|
require File.dirname(__FILE__) + '/../modules/ImageProcessing.rb'
|
2010-03-24 01:24:27 +00:00
|
|
|
require 'fileutils'
|
2010-01-07 03:56:52 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Process an input file for the Web
|
|
|
|
#
|
|
|
|
class TempBitmapToWeb < OutputFilter
|
2010-01-10 22:12:23 +00:00
|
|
|
include ImageProcessing
|
|
|
|
|
2010-01-07 03:56:52 +00:00
|
|
|
def build(input, output)
|
2010-03-24 01:24:27 +00:00
|
|
|
FileUtils.mkdir_p(File.split(output).first)
|
2010-01-07 03:56:52 +00:00
|
|
|
quality = @config['quality'] ? @config['quality'] : 80
|
|
|
|
convert("\"#{input}\" -quality #{quality} \"#{output}\"")
|
|
|
|
end
|
|
|
|
|
|
|
|
def filename(info)
|
2010-01-10 22:12:23 +00:00
|
|
|
info['date'] = @config['publish_dates'][info['index'].to_i - 1].strftime(@config['date_format'])
|
2010-03-24 01:24:27 +00:00
|
|
|
info['subdir'] = ''
|
|
|
|
if @config['subdirs']
|
|
|
|
@config['subdirs'].each do |dir, subdir_info|
|
|
|
|
if Range.new(subdir_info['from'].to_i, subdir_info['to'].to_i).include? info['index'].to_i
|
|
|
|
info['subdir'] = dir + File::SEPARATOR
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-07 03:56:52 +00:00
|
|
|
super(info)
|
|
|
|
end
|
|
|
|
end
|