improved width & height calculations for print

This commit is contained in:
John Bintz 2009-03-31 23:01:44 -04:00
parent 4c19101b1d
commit 545a665926

View File

@ -24,11 +24,16 @@ class Filter
def recalc_pixels def recalc_pixels
if @config['print'] if @config['print']
if @config['width_inches'] && @config['width_inches'] != 0 if !@config['dpi']; raise "DPI not defined"; end
@config['width'] = @config['width_inches'].to_i * @config['dpi'].to_i if @config['width_inches'] && (@config['width_inches'].to_f != 0)
@config['width'] = (@config['width_inches'].to_f * @config['dpi'].to_f).to_i
else
@config.delete('width')
end end
if @config['height_inches'] && @config['height_inches'] != 0 if @config['height_inches'] && (@config['height_inches'].to_f != 0)
@config['height'] = @config['height_inches'].to_i * @config['dpi'].to_i @config['height'] = (@config['height_inches'].to_f * @config['dpi'].to_f).to_i
else
@config.delete('height')
end end
end end
end end
@ -60,8 +65,8 @@ class Filter
end end
end end
if width; params << "-w #{width} "; end if width && (width.to_i != 0); params << "-w #{width} "; end
if height; params << "-h #{height} "; end if height && (height.to_i != 0); params << "-h #{height} "; end
system("inkscape -e \"#{inkscape_target}\" -y 1.0 #{params.join(" ")} \"#{input}\"") system("inkscape -e \"#{inkscape_target}\" -y 1.0 #{params.join(" ")} \"#{input}\"")