Class: FormatParser::Image

Inherits:
Object
  • Object
show all
Includes:
AttributesJSON
Defined in:
lib/image.rb

Constant Summary collapse

NATURE =
:image

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributesJSON

#as_json, #to_json

Constructor Details

#initialize(**attributes) ⇒ Image

Only permits assignments via defined accessors



50
51
52
# File 'lib/image.rb', line 50

def initialize(**attributes)
  attributes.map { |(k, v)| public_send("#{k}=", v) }
end

Instance Attribute Details

#color_modeObject

Basic information about the color mode



29
30
31
# File 'lib/image.rb', line 29

def color_mode
  @color_mode
end

#formatObject

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



10
11
12
# File 'lib/image.rb', line 10

def format
  @format
end

#has_multiple_framesObject

Whether the file has multiple frames (relevant for image files and video)



19
20
21
# File 'lib/image.rb', line 19

def has_multiple_frames
  @has_multiple_frames
end

#has_transparencyObject

Whether the image has transparency (or an alpha channel)



26
27
28
# File 'lib/image.rb', line 26

def has_transparency
  @has_transparency
end

#height_pxObject

Number of pixels vertically in the pixel buffer



16
17
18
# File 'lib/image.rb', line 16

def height_px
  @height_px
end

#image_orientationObject

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: magnushoff.com/jpeg-orientation.html



43
44
45
# File 'lib/image.rb', line 43

def image_orientation
  @image_orientation
end

#intrinsicsObject

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



47
48
49
# File 'lib/image.rb', line 47

def intrinsics
  @intrinsics
end

#num_animation_or_video_framesObject

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.



37
38
39
# File 'lib/image.rb', line 37

def num_animation_or_video_frames
  @num_animation_or_video_frames
end

#orientationObject

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



23
24
25
# File 'lib/image.rb', line 23

def orientation
  @orientation
end

#width_pxObject

Number of pixels horizontally in the pixel buffer



13
14
15
# File 'lib/image.rb', line 13

def width_px
  @width_px
end

Instance Method Details

#natureObject



54
55
56
# File 'lib/image.rb', line 54

def nature
  NATURE
end