Class: Pdf::Reader::ExtractImages::Jpg
- Inherits:
-
Object
- Object
- Pdf::Reader::ExtractImages::Jpg
- Defined in:
- lib/pdf/reader/extract_images/jpg.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(stream) ⇒ Jpg
constructor
A new instance of Jpg.
- #save(filename) ⇒ Object
Constructor Details
#initialize(stream) ⇒ Jpg
Returns a new instance of Jpg.
7 8 9 |
# File 'lib/pdf/reader/extract_images/jpg.rb', line 7 def initialize(stream) @stream = stream end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
5 6 7 |
# File 'lib/pdf/reader/extract_images/jpg.rb', line 5 def stream @stream end |
Instance Method Details
#save(filename) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pdf/reader/extract_images/jpg.rb', line 11 def save(filename) w = stream.hash[:Width] h = stream.hash[:Height] blob = stream.data if stream.hash[:ColorSpace] == :DeviceCMYK && stream.data['Adobe'] blob = Tempfile.open(['extract', filename]) { |tf| tf.binmode tf.write stream.data tf.flush ImageProcessing::MiniMagick.source(tf.path).negate.call.read } end { filename: filename, blob: blob, width: w, height: h } end |