Class: FormatParser::Image
- Inherits:
-
Object
- Object
- FormatParser::Image
- Includes:
- AttributesJSON
- Defined in:
- lib/image.rb
Constant Summary collapse
- NATURE =
:image
Instance Attribute Summary collapse
-
#color_mode ⇒ Object
Basic information about the color mode.
-
#format ⇒ Object
What filetype was recognized? Will contain a non-ambiguous symbol referring to the file format.
-
#has_multiple_frames ⇒ Object
Whether the file has multiple frames (relevant for image files and video).
-
#has_transparency ⇒ Object
Whether the image has transparency (or an alpha channel).
-
#height_px ⇒ Object
Number of pixels vertically in the pixel buffer.
-
#image_orientation ⇒ Object
Orientation from EXIF data.
-
#intrinsics ⇒ Object
If a parser wants to provide any extra information to the caller it can be placed here.
-
#num_animation_or_video_frames ⇒ Object
If the file has animation or is video, this might indicate the number of frames.
-
#orientation ⇒ Object
The angle by which the camera was rotated when taking the picture (affects display width and height).
-
#width_px ⇒ Object
Number of pixels horizontally in the pixel buffer.
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Image
constructor
Only permits assignments via defined accessors.
- #nature ⇒ Object
Methods included from AttributesJSON
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_mode ⇒ Object
Basic information about the color mode
29 30 31 |
# File 'lib/image.rb', line 29 def color_mode @color_mode end |
#format ⇒ Object
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_frames ⇒ Object
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_transparency ⇒ Object
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_px ⇒ Object
Number of pixels vertically in the pixel buffer
16 17 18 |
# File 'lib/image.rb', line 16 def height_px @height_px end |
#image_orientation ⇒ Object
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 |
#intrinsics ⇒ Object
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_frames ⇒ Object
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 |
#orientation ⇒ Object
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_px ⇒ Object
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
#nature ⇒ Object
54 55 56 |
# File 'lib/image.rb', line 54 def nature NATURE end |