summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-02 03:38:16 -0500
committerPeter Kozak <spag@golwen.net>2013-03-02 03:38:16 -0500
commit6ed538ee9385245a7bbac838dd5b796bba2ea0c6 (patch)
tree9e11929fd865b4e9529479423efa3aba3f7642a6 /app/models
parentecf2b91a0b0538b60fb708a237e10af77afe33dc (diff)
use imagemagick when ghostscript fails
Diffstat (limited to 'app/models')
-rw-r--r--app/models/fax_document.rb11
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