Sha256: 2cccfd75a54a6b847eb23e1e2111d27f12adeca86a4fc6d6108ca628578799a1

Contents?: true

Size: 1.84 KB

Versions: 15

Compression:

Stored size: 1.84 KB

Contents

module FormatParser
  class Image
    include FormatParser::AttributesJSON

    NATURE = :image

    # What filetype was recognized? Will contain a non-ambiguous symbol
    # referring to the file format. The symbol can be used as a filename
    # extension safely
    attr_accessor :format

    # Number of pixels horizontally in the pixel buffer
    attr_accessor :width_px

    # Number of pixels vertically in the pixel buffer
    attr_accessor :height_px

    # Whether the file has multiple frames (relevant for image files and video)
    attr_accessor :has_multiple_frames

    # The angle by which the camera was rotated when taking the picture
    # (affects display width and height)
    attr_accessor :orientation

    # Whether the image has transparency (or an alpha channel)
    attr_accessor :has_transparency

    # Basic information about the color mode
    attr_accessor :color_mode

    # If the file has animation or is video, this might
    # indicate the number of frames. Some formats do not
    # allow retrieving this value without parsing the entire
    # file, so for GIF this might be nil even though it is
    # animated. For a boolean check, `has_multiple_frames`
    # might offer a better clue.
    attr_accessor :num_animation_or_video_frames

    # Orientation from EXIF data. Will come through as an integer.
    # To be perfectly honest EXIF orientation handling is a bit of a mess,
    # here's a reasonable blog post about it:
    # http://magnushoff.com/jpeg-orientation.html
    attr_accessor :image_orientation

    # If a parser wants to provide any extra information to the caller
    # it can be placed here
    attr_accessor :intrinsics

    # Only permits assignments via defined accessors
    def initialize(**attributes)
      attributes.map { |(k, v)| public_send("#{k}=", v) }
    end

    def nature
      NATURE
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
format_parser-0.10.0 lib/image.rb
format_parser-0.9.4 lib/image.rb
format_parser-0.9.3 lib/image.rb
format_parser-0.9.0 lib/image.rb
format_parser-0.8.0 lib/image.rb
format_parser-0.7.0 lib/image.rb
format_parser-0.6.0 lib/image.rb
format_parser-0.5.2 lib/image.rb
format_parser-0.5.1 lib/image.rb
format_parser-0.5.0 lib/image.rb
format_parser-0.4.0 lib/image.rb
format_parser-0.3.5 lib/image.rb
format_parser-0.3.4 lib/image.rb
format_parser-0.3.3 lib/image.rb
format_parser-0.3.2 lib/image.rb