Skip to content
Browse files

close #883 use docsplit api instead of cmdline

  • Loading branch information...
1 parent 0ab1f51 commit 31cadff4322546aec97f89b5de6985a5029384dd @mfrederickson mfrederickson committed Feb 19, 2014
Showing with 6 additions and 8 deletions.
  1. +6 −8 lib/concerto/content_converter.rb
View
14 lib/concerto/content_converter.rb
@@ -68,10 +68,10 @@ def self.convert(media)
f.write original_media.file_contents
end
- # process it with docsplit
- cmd = "docsplit images -p 1 -f png -o /tmp '#{original_filepath}' 2>&1"
- result = `#{cmd}`
- if $?.exitstatus == 0
+ # process it with docsplit via the api
+ begin
+ Docsplit.extract_images("#{original_filepath}", :pages => 1, :format => 'png', :output => "/tmp")
+
# if all went well, get the new filename... which has the _pageno appended to it
new_filename = "#{File.basename(original_filepath,".*")}_1.png"
new_filepath = File.join( File.dirname(original_filepath), new_filename)
@@ -90,10 +90,8 @@ def self.convert(media)
File.delete(original_filepath) if File.exist?(original_filepath)
File.delete(new_filepath) if File.exist?(new_filepath)
return media
- else
- # command failed
- Rails.logger.error(cmd)
- Rails.logger.error(result)
+ rescue Docsplit::ExtractionFailed => e
+ Rails.logger.error(e.message.chomp)
raise Unconvertable.new("Unable to convert #{original_media.file_name}")
end
end

0 comments on commit 31cadff

Please sign in to comment.
Something went wrong with that request. Please try again.