Skip to content

Commit 77a3e77

Browse files
committed
Merge pull request #13 from simeonwillbanks/master
Inspect file mime-type
2 parents df32144 + 770ec68 commit 77a3e77

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/docsplit.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Docsplit
1515

1616
METADATA_KEYS = [:author, :date, :creator, :keywords, :producer, :subject, :title, :length]
1717

18-
GM_FORMATS = [:png, :gif, :jpg, :jpeg, :tif, :tiff, :bmp, :pnm, :ppm, :svg, :eps]
18+
GM_FORMATS = ["image/gif", "image/jpeg", "image/png", "image/x-ms-bmp", "image/svg+xml", "image/tiff", "image/x-portable-bitmap", "application/postscript", "image/x-portable-pixmap"]
1919

2020
DEPENDENCIES = {:java => false, :gm => false, :pdftotext => false, :pdftk => false, :tesseract => false}
2121

@@ -65,7 +65,7 @@ def self.extract_pdf(docs, opts={})
6565
basename = File.basename(doc, ext)
6666
escaped_doc, escaped_out, escaped_basename = [doc, out, basename].map(&ESCAPE)
6767

68-
if ext.length > 0 && GM_FORMATS.include?(ext.sub(/^\./, '').downcase.to_sym)
68+
if GM_FORMATS.include?(`file -b --mime-type #{doc}`.strip)
6969
`gm convert #{escaped_doc} #{escaped_out}/#{escaped_basename}.pdf`
7070
else
7171
options = "-jar #{ROOT}/vendor/jodconverter/jodconverter-core-3.0-beta-3.jar -r #{ROOT}/vendor/conf/document-formats.js"

0 commit comments

Comments
 (0)