libis-format 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +19 -23
  4. data/Gemfile +0 -2
  5. data/README.md +2 -2
  6. data/base/Dockerfile +5 -3
  7. data/base/rework_path +5 -10
  8. data/data/PDFA_def.ps +3 -3
  9. data/data/eciRGB_v2.icc +0 -0
  10. data/lib/libis/format/cli/convert.rb +4 -4
  11. data/lib/libis/format/config.rb +3 -3
  12. data/lib/libis/format/converter/audio_converter.rb +6 -38
  13. data/lib/libis/format/converter/base.rb +21 -8
  14. data/lib/libis/format/converter/chain.rb +7 -19
  15. data/lib/libis/format/converter/fop_pdf_converter.rb +2 -0
  16. data/lib/libis/format/converter/image_assembler.rb +82 -0
  17. data/lib/libis/format/converter/image_converter.rb +21 -141
  18. data/lib/libis/format/converter/image_splitter.rb +80 -0
  19. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  20. data/lib/libis/format/converter/jp2_converter.rb +4 -4
  21. data/lib/libis/format/converter/office_converter.rb +5 -3
  22. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  23. data/lib/libis/format/converter/pdf_converter.rb +31 -98
  24. data/lib/libis/format/converter/pdf_optimizer.rb +70 -0
  25. data/lib/libis/format/converter/pdf_splitter.rb +65 -0
  26. data/lib/libis/format/converter/pdf_watermarker.rb +110 -0
  27. data/lib/libis/format/converter/spreadsheet_converter.rb +5 -3
  28. data/lib/libis/format/converter/video_converter.rb +3 -6
  29. data/lib/libis/format/converter/xslt_converter.rb +14 -15
  30. data/lib/libis/format/identifier.rb +3 -3
  31. data/lib/libis/format/info.rb +27 -0
  32. data/lib/libis/format/library.rb +147 -0
  33. data/lib/libis/format/tool/extension_identification.rb +4 -4
  34. data/lib/libis/format/tool/{ff_mpeg.rb → ffmpeg.rb} +1 -10
  35. data/lib/libis/format/tool/fop_pdf.rb +0 -12
  36. data/lib/libis/format/tool/identification_tool.rb +6 -6
  37. data/lib/libis/format/tool/office_to_pdf.rb +1 -10
  38. data/lib/libis/format/tool/pdf_copy.rb +1 -11
  39. data/lib/libis/format/tool/pdf_merge.rb +1 -11
  40. data/lib/libis/format/tool/pdf_optimizer.rb +2 -11
  41. data/lib/libis/format/tool/pdf_split.rb +1 -11
  42. data/lib/libis/format/tool/pdf_to_pdfa.rb +43 -59
  43. data/lib/libis/format/tool/pdfa_validator.rb +35 -28
  44. data/lib/libis/format/tool/spreadsheet_to_ods.rb +2 -10
  45. data/lib/libis/format/tool.rb +1 -1
  46. data/lib/libis/format/version.rb +1 -1
  47. data/lib/libis/format/yaml_loader.rb +71 -0
  48. data/lib/libis/format.rb +5 -2
  49. data/libis-format.gemspec +3 -5
  50. data/tools/fop/fop.bat +75 -75
  51. data/tools/fop/fop.cmd +31 -31
  52. data/tools/fop/fop.js +341 -341
  53. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -11
  54. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -17
  55. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -74
  56. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -66
  57. metadata +19 -29
  58. data/data/AdobeRGB1998.icc +0 -0
  59. data/lib/libis/format/converter/email_converter.rb +0 -38
  60. data/lib/libis/format/tool/email_to_pdf.rb +0 -75
  61. data/lib/libis/format/type_database.rb +0 -133
  62. data/lib/libis/format/type_database_impl.rb +0 -120
  63. data/tools/emailconverter.jar +0 -0
  64. data/tools/pdf2pdfa +0 -395
  65. /data/bin/{droid_tool → droid} +0 -0
  66. /data/bin/{fido_tool → fido} +0 -0
@@ -1,3 +1,4 @@
1
+ # noinspection RubyResolve
1
2
  require 'fileutils'
2
3
 
3
4
  require 'libis/tools/extend/string'
@@ -13,11 +14,6 @@ module Libis
13
14
  class SpreadsheetToOds
14
15
  include ::Libis::Tools::Logger
15
16
 
16
- def self.installed?
17
- result = Libis::Tools::Command.run(Libis::Format::Config[:soffice_cmd], "--version")
18
- result == 0
19
- end
20
-
21
17
  def self.run(source, target, options = {})
22
18
  self.new.run source, target, options
23
19
  end
@@ -53,14 +49,10 @@ module Libis
53
49
 
54
50
  FileUtils.copy tgt_file, target, preserve: true
55
51
 
56
- {
57
- command: result,
58
- files: [ target ]
59
- }
60
-
61
52
  ensure
62
53
  FileUtils.rmtree workdir rescue nil
63
54
 
55
+ result[:out]
64
56
  end
65
57
  end
66
58
 
@@ -10,7 +10,7 @@ module Libis
10
10
  autoload :FileTool, 'libis/format/tool/file_tool'
11
11
 
12
12
  autoload :OfficeToPdf, 'libis/format/tool/office_to_pdf'
13
- autoload :FFMpeg, 'libis/format/tool/ff_mpeg'
13
+ autoload :FFMpeg, 'libis/format/tool/ffmpeg'
14
14
  autoload :FopPdf, 'libis/format/tool/fop_pdf'
15
15
  autoload :PdfCopy, 'libis/format/tool/pdf_copy'
16
16
  autoload :PdfMerge, 'libis/format/tool/pdf_merge'
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '1.2.1'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+ require 'singleton'
4
+
5
+ module Libis
6
+ module Format
7
+ class YamlLoader
8
+ # noinspection RubyResolve
9
+ include Singleton
10
+
11
+ def query(key, value)
12
+ case key.to_s.downcase.to_sym
13
+ when :name
14
+ return [database[value.to_s.upcase.to_sym]]
15
+ when :category
16
+ database.find_all { |_, info| info.category == value.to_s.upcase.to_sym }
17
+ when :puid
18
+ database.find_all { |_, info| info.puids.include?(value) }
19
+ when :mimetype
20
+ database.find_all { |_, info| info.mimetypes.include?(value) }
21
+ when :extension
22
+ database.find_all { |_, info| info.extensions.include?(value) }
23
+ else
24
+ return []
25
+ end.map(&:last)
26
+ end
27
+
28
+ def load_formats(file_or_hash)
29
+ hash = file_or_hash.is_a?(Hash) ? file_or_hash : YAML::load_file(file_or_hash)
30
+ hash.each do |category, format_list|
31
+ format_list.each do |format_name, format_info|
32
+ format_info.symbolize_keys!
33
+ format_name = format_name.to_sym
34
+ new_info = Libis::Format::Info.new(
35
+ name: format_name,
36
+ category: category.to_sym,
37
+ description: format_info[:NAME],
38
+ puids: format_info[:PUID]&.strip&.split(/[\s,]+/)&.map { |v| v.strip } || [],
39
+ mimetypes: format_info[:MIME]&.strip&.split(/[\s,]+/)&.map(&:strip) || [],
40
+ extensions: format_info[:EXTENSIONS]&.strip&.split(/[\s,]+/)&.map { |v| v.strip } || []
41
+ )
42
+ if (old_info = database[format_name])
43
+ new_info = Libis::Format::Info.new(
44
+ name: format_name,
45
+ category: category.to_sym,
46
+ description: new_info.description.blank? ? old_info.description : new_info.description,
47
+ puids: (old_info.puids + new_info.puids).uniq,
48
+ mimetypes: (old_info.mimetypes + new_info.mimetypes).uniq,
49
+ extensions: (old_info.extensions + new_info.extensions).uniq
50
+ )
51
+ end
52
+ database[format_name] = new_info
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ private
59
+
60
+ attr_reader :database
61
+
62
+ def initialize
63
+ @database = {}
64
+ format_database = Libis::Format::Config[:format_library_database]
65
+ load_formats(format_database)
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+ end
data/lib/libis/format.rb CHANGED
@@ -3,8 +3,11 @@ require 'libis/format/version'
3
3
  module Libis
4
4
  module Format
5
5
  autoload :Config, 'libis/format/config'
6
- autoload :TypeDatabase, 'libis/format/type_database'
7
- autoload :TypeDatabaseImpl, 'libis/format/type_database_impl'
6
+
7
+ autoload :Info, 'libis/format/info'
8
+ autoload :Library, 'libis/format/library'
9
+ autoload :YamlLoader, 'libis/format/yaml_loader'
10
+
8
11
  autoload :Identifier, 'libis/format/identifier'
9
12
 
10
13
  autoload :Tool, 'libis/format/tool'
data/libis-format.gemspec CHANGED
@@ -3,8 +3,8 @@
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
- require 'libis/format/version'
7
6
  require 'bundler'
7
+ require 'libis/format/version'
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = 'libis-format'
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec', '~> 3.1'
28
28
  spec.add_development_dependency 'awesome_print'
29
29
  spec.add_development_dependency 'equivalent-xml', '~> 0.5'
30
- if Gem::Platform::JAVA && spec.platform == Gem::Platform::JAVA
30
+ if spec.platform == Gem::Platform::JAVA
31
31
  spec.add_development_dependency 'saxon-xslt'
32
32
  else
33
33
  spec.add_development_dependency 'nokogiri'
@@ -39,6 +39,4 @@ Gem::Specification.new do |spec|
39
39
  spec.add_runtime_dependency 'deep_dive', '~> 0.3'
40
40
  spec.add_runtime_dependency 'chromaprint', '~> 0.0.2'
41
41
  spec.add_runtime_dependency 'naturally', '~> 2.1'
42
- spec.add_runtime_dependency 'pdfinfo', '~> 1.4'
43
-
44
- end
42
+ end
data/tools/fop/fop.bat CHANGED
@@ -1,75 +1,75 @@
1
- @ECHO OFF
2
- REM Licensed to the Apache Software Foundation (ASF) under one or more
3
- REM contributor license agreements. See the NOTICE file distributed with
4
- REM this work for additional information regarding copyright ownership.
5
- REM The ASF licenses this file to You under the Apache License, Version 2.0
6
- REM (the "License"); you may not use this file except in compliance with
7
- REM the License. You may obtain a copy of the License at
8
- REM
9
- REM http://www.apache.org/licenses/LICENSE-2.0
10
- REM
11
- REM Unless required by applicable law or agreed to in writing, software
12
- REM distributed under the License is distributed on an "AS IS" BASIS,
13
- REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- REM See the License for the specific language governing permissions and
15
- REM limitations under the License.
16
- REM $Id: fop.bat 1736993 2016-03-29 09:19:30Z ssteiner $
17
-
18
- SETLOCAL ENABLEDELAYEDEXPANSION
19
-
20
- rem %~dp0 is the expanded pathname of the current script under NT
21
- set LOCAL_FOP_HOME=
22
- if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME="%~dp0"
23
-
24
- rem Code from Apache Ant project
25
- rem Slurp the command line arguments. This loop allows for an unlimited number
26
- rem of arguments (up to the command line limit, anyway).
27
- rem Could also do a "shift" and "%*" for all params, but apparently doesn't work
28
- rem with Win9x.
29
- set FOP_CMD_LINE_ARGS=%1
30
- if ""%1""=="""" goto doneStart
31
- shift
32
- :setupArgs
33
- if ""%1""=="""" goto doneStart
34
- set FOP_CMD_LINE_ARGS=%FOP_CMD_LINE_ARGS% %1
35
- shift
36
- goto setupArgs
37
- rem This label provides a place for the argument list loop to break out
38
- rem and for NT handling to skip to.
39
- :doneStart
40
-
41
- set LOGCHOICE=
42
- rem The default commons logger for JDK1.4 is JDK1.4Logger.
43
- rem To use a different logger, uncomment the one desired below
44
- rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
45
- rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
46
- rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
47
-
48
- set LOGLEVEL=
49
- rem Logging levels
50
- rem Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger.
51
- rem To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%\JRE\LIB\logging.properties
52
- rem file instead.
53
- rem Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
54
- rem set LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO
55
-
56
- set LIBDIR=%LOCAL_FOP_HOME%lib
57
-
58
- set LOCALCLASSPATH=%FOP_HYPHENATION_PATH%
59
- for %%l in (%LOCAL_FOP_HOME%build\*.jar %LIBDIR%\*.jar %LOCAL_FOP_HOME%target\*.jar) do set LOCALCLASSPATH=!LOCALCLASSPATH!;%%l
60
-
61
- set JAVAOPTS=-Denv.windir=%WINDIR%
62
-
63
- if "%JAVA_HOME%" == "" goto noJavaHome
64
- if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
65
- if "%JAVACMD%" == "" set JAVACMD=%JAVA_HOME%\bin\java
66
- goto runFop
67
-
68
- :noJavaHome
69
- if "%JAVACMD%" == "" set JAVACMD=java
70
-
71
- :runFop
72
- rem echo "%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
73
- "%JAVACMD%" %JAVAOPTS% %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" %FOP_OPTS% org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
74
-
75
- ENDLOCAL
1
+ @ECHO OFF
2
+ REM Licensed to the Apache Software Foundation (ASF) under one or more
3
+ REM contributor license agreements. See the NOTICE file distributed with
4
+ REM this work for additional information regarding copyright ownership.
5
+ REM The ASF licenses this file to You under the Apache License, Version 2.0
6
+ REM (the "License"); you may not use this file except in compliance with
7
+ REM the License. You may obtain a copy of the License at
8
+ REM
9
+ REM http://www.apache.org/licenses/LICENSE-2.0
10
+ REM
11
+ REM Unless required by applicable law or agreed to in writing, software
12
+ REM distributed under the License is distributed on an "AS IS" BASIS,
13
+ REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ REM See the License for the specific language governing permissions and
15
+ REM limitations under the License.
16
+ REM $Id: fop.bat 1736993 2016-03-29 09:19:30Z ssteiner $
17
+
18
+ SETLOCAL ENABLEDELAYEDEXPANSION
19
+
20
+ rem %~dp0 is the expanded pathname of the current script under NT
21
+ set LOCAL_FOP_HOME=
22
+ if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME="%~dp0"
23
+
24
+ rem Code from Apache Ant project
25
+ rem Slurp the command line arguments. This loop allows for an unlimited number
26
+ rem of arguments (up to the command line limit, anyway).
27
+ rem Could also do a "shift" and "%*" for all params, but apparently doesn't work
28
+ rem with Win9x.
29
+ set FOP_CMD_LINE_ARGS=%1
30
+ if ""%1""=="""" goto doneStart
31
+ shift
32
+ :setupArgs
33
+ if ""%1""=="""" goto doneStart
34
+ set FOP_CMD_LINE_ARGS=%FOP_CMD_LINE_ARGS% %1
35
+ shift
36
+ goto setupArgs
37
+ rem This label provides a place for the argument list loop to break out
38
+ rem and for NT handling to skip to.
39
+ :doneStart
40
+
41
+ set LOGCHOICE=
42
+ rem The default commons logger for JDK1.4 is JDK1.4Logger.
43
+ rem To use a different logger, uncomment the one desired below
44
+ rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
45
+ rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
46
+ rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
47
+
48
+ set LOGLEVEL=
49
+ rem Logging levels
50
+ rem Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger.
51
+ rem To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%\JRE\LIB\logging.properties
52
+ rem file instead.
53
+ rem Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
54
+ rem set LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO
55
+
56
+ set LIBDIR=%LOCAL_FOP_HOME%lib
57
+
58
+ set LOCALCLASSPATH=%FOP_HYPHENATION_PATH%
59
+ for %%l in (%LOCAL_FOP_HOME%build\*.jar %LIBDIR%\*.jar %LOCAL_FOP_HOME%target\*.jar) do set LOCALCLASSPATH=!LOCALCLASSPATH!;%%l
60
+
61
+ set JAVAOPTS=-Denv.windir=%WINDIR%
62
+
63
+ if "%JAVA_HOME%" == "" goto noJavaHome
64
+ if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
65
+ if "%JAVACMD%" == "" set JAVACMD=%JAVA_HOME%\bin\java
66
+ goto runFop
67
+
68
+ :noJavaHome
69
+ if "%JAVACMD%" == "" set JAVACMD=java
70
+
71
+ :runFop
72
+ rem echo "%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
73
+ "%JAVACMD%" %JAVAOPTS% %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" %FOP_OPTS% org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
74
+
75
+ ENDLOCAL
data/tools/fop/fop.cmd CHANGED
@@ -1,31 +1,31 @@
1
- @ECHO OFF
2
- REM Licensed to the Apache Software Foundation (ASF) under one or more
3
- REM contributor license agreements. See the NOTICE file distributed with
4
- REM this work for additional information regarding copyright ownership.
5
- REM The ASF licenses this file to You under the Apache License, Version 2.0
6
- REM (the "License"); you may not use this file except in compliance with
7
- REM the License. You may obtain a copy of the License at
8
- REM
9
- REM http://www.apache.org/licenses/LICENSE-2.0
10
- REM
11
- REM Unless required by applicable law or agreed to in writing, software
12
- REM distributed under the License is distributed on an "AS IS" BASIS,
13
- REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- REM See the License for the specific language governing permissions and
15
- REM limitations under the License.
16
- REM $Id: fop.cmd 1734671 2016-03-12 05:39:53Z gadams $
17
-
18
- set LOCAL_FOP_HOME=%~dp0
19
- set FOP_CMD_LINE_ARGS=%1
20
- if ""%1""=="""" goto doneStart
21
- shift
22
- :setupArgs
23
- if ""%1""=="""" goto doneStart
24
- set FOP_CMD_LINE_ARGS=%FOP_CMD_LINE_ARGS% %1
25
- shift
26
- goto setupArgs
27
- rem This label provides a place for the argument list loop to break out
28
- :doneStart
29
-
30
- call "%LOCAL_FOP_HOME%\fop.bat" %FOP_CMD_LINE_ARGS%
31
-
1
+ @ECHO OFF
2
+ REM Licensed to the Apache Software Foundation (ASF) under one or more
3
+ REM contributor license agreements. See the NOTICE file distributed with
4
+ REM this work for additional information regarding copyright ownership.
5
+ REM The ASF licenses this file to You under the Apache License, Version 2.0
6
+ REM (the "License"); you may not use this file except in compliance with
7
+ REM the License. You may obtain a copy of the License at
8
+ REM
9
+ REM http://www.apache.org/licenses/LICENSE-2.0
10
+ REM
11
+ REM Unless required by applicable law or agreed to in writing, software
12
+ REM distributed under the License is distributed on an "AS IS" BASIS,
13
+ REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ REM See the License for the specific language governing permissions and
15
+ REM limitations under the License.
16
+ REM $Id: fop.cmd 1734671 2016-03-12 05:39:53Z gadams $
17
+
18
+ set LOCAL_FOP_HOME=%~dp0
19
+ set FOP_CMD_LINE_ARGS=%1
20
+ if ""%1""=="""" goto doneStart
21
+ shift
22
+ :setupArgs
23
+ if ""%1""=="""" goto doneStart
24
+ set FOP_CMD_LINE_ARGS=%FOP_CMD_LINE_ARGS% %1
25
+ shift
26
+ goto setupArgs
27
+ rem This label provides a place for the argument list loop to break out
28
+ :doneStart
29
+
30
+ call "%LOCAL_FOP_HOME%\fop.bat" %FOP_CMD_LINE_ARGS%
31
+