Class: Riiif::VipsInfoExtractor
- Inherits:
-
AbstractInfoExtractor
- Object
- AbstractInfoExtractor
- Riiif::VipsInfoExtractor
- Defined in:
- app/extractors/riiif/vips_info_extractor.rb
Overview
Get information using (lib)vips to interrogate the file
Instance Method Summary collapse
Methods inherited from AbstractInfoExtractor
Constructor Details
This class inherits a constructor from Riiif::AbstractInfoExtractor
Instance Method Details
#extract ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/extractors/riiif/vips_info_extractor.rb', line 8 def extract attributes = Riiif::CommandRunner.execute("#{external_command} '#{@path}' -a") .split(/\n/) .map { |str| str.strip.split(': ') }.to_h width, height = attributes.values_at("width", "height") { height: Integer(height), width: Integer(width), format: attributes["vips-loader"].match?("pngload") ? "PNG" : "JPEG", channels: ::Vips::Image.new_from_file(@path.to_s).has_alpha? ? "srgba" : "srgb" } end |