Class: Libis::Format::Converter::ImageSplitter
- Inherits:
-
Base
- Object
- Base
- Libis::Format::Converter::ImageSplitter
show all
- Defined in:
- lib/libis/format/converter/image_splitter.rb
Instance Attribute Summary
Attributes inherited from Base
#flags, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#check_file_exist, inherited, #initialize, using_temp, #using_temp
Class Method Details
36
37
38
|
# File 'lib/libis/format/converter/image_splitter.rb', line 36
def self.category
:splitter
end
|
23
24
25
|
# File 'lib/libis/format/converter/image_splitter.rb', line 23
def self.input_types
[:PDF, :TIFF, :GIF, :PBM, :PGM, :PPM]
end
|
.multipage?(format) ⇒ Boolean
32
33
34
|
# File 'lib/libis/format/converter/image_splitter.rb', line 32
def self.multipage?(format)
[:PDF, :TIFF, :GIF, :PBM, :PGM, :PPM].include?(format)
end
|
.output_types(format = nil) ⇒ Object
27
28
29
30
|
# File 'lib/libis/format/converter/image_splitter.rb', line 27
def self.output_types(format = nil)
return [] unless input_types.include?(format) if format
[:TIFF, :JPG, :PNG, :BMP, :GIF, :PDF, :JP2]
end
|
Instance Method Details
#convert(source, target, format, opts = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/libis/format/converter/image_splitter.rb', line 48
def convert(source, target, format, opts = {})
super
FileUtils.mkpath(File.dirname(target))
if self.class.multipage?(format)
target = File.join(File.dirname(target), "#{File.basename(target, '.*')}-%d#{File.extname(target)}")
end
result = split_image(source, target, format)
return nil unless result
target
end
|
#image_split(_) ⇒ Object
40
41
42
|
# File 'lib/libis/format/converter/image_splitter.rb', line 40
def image_split(_)
end
|
44
45
46
|
# File 'lib/libis/format/converter/image_splitter.rb', line 44
def quiet(v)
@quiet = !!v
end
|