diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-02 03:38:16 -0500 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-02 03:38:16 -0500 |
commit | 6ed538ee9385245a7bbac838dd5b796bba2ea0c6 (patch) | |
tree | 9e11929fd865b4e9529479423efa3aba3f7642a6 /app/models | |
parent | ecf2b91a0b0538b60fb708a237e10af77afe33dc (diff) |
use imagemagick when ghostscript fails
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/fax_document.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index 5b27965..3cb92ea 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -96,9 +96,18 @@ class FaxDocument < ActiveRecord::Base page_size_command = "<< /Policies << /PageSize 3 >> /InputAttributes currentpagedevice /InputAttributes get dup { pop 1 index exch undef } forall dup 0 << /PageSize [ #{page_size_a4} ] >> put >> setpagedevice" working_path, file_name = File.split(self.document.to_s) tiff_file = File.basename(file_name.to_s.downcase, File.extname(file_name)) + '.tiff' - result = system "cd #{store_dir} && gs -q -r#{self.fax_resolution.resolution_value} -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=\"#{tiff_file}\" -c \"#{page_size_command}\" -- \"#{self.document.to_s}\"" + result = system "cd #{store_dir} && gs -q -r#{self.fax_resolution.resolution_value} -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=\"#{store_dir}/#{tiff_file}\" -c \"#{page_size_command}\" -- \"#{self.document.to_s}\"" if !File.exists?("#{store_dir}/#{tiff_file}") + page_size = "1728x1078" or "1728x1186"; + command = "cd #{store_dir} && convert -quiet -density #{self.fax_resolution.resolution_value} -units PixelsPerInch -resize #{page_size}\! -monochrome -compress Fax \"#{self.document.to_s}\" \"#{store_dir}/#{tiff_file}\"" + result = system(command) + if result.nil? + logger.error "### FAX_DOCUMENT_TO_TIFF - error: #{$?}, command: #{command}" + end + end + + if !File.exists?("#{store_dir}/#{tiff_file}") return nil end |