Class: Natour::Image
- Inherits:
-
Object
- Object
- Natour::Image
- Defined in:
- lib/natour/image.rb
Instance Attribute Summary collapse
-
#date_time ⇒ Object
readonly
Returns the value of attribute date_time.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #autorotate ⇒ Object
-
#initialize(path, image) ⇒ Image
constructor
A new instance of Image.
- #landscape? ⇒ Boolean
- #save_as(filename) ⇒ Object
- #shrink_to(maxdim) ⇒ Object
Constructor Details
#initialize(path, image) ⇒ Image
Returns a new instance of Image.
11 12 13 14 15 16 17 18 19 |
# File 'lib/natour/image.rb', line 11 def initialize(path, image) @path = path @image = image @landscape = image.width >= image.height orientation = get_field('exif-ifd0-Orientation') @landscape = !@landscape if orientation && orientation[/^(\d) \(/, 1].to_i.between?(5, 8) date_time = get_field('exif-ifd0-DateTime') @date_time = Timeliness.parse(date_time[/^(.*?) \(/, 1], format: 'yyyy:mm:dd hh:nn:ss') if date_time end |
Instance Attribute Details
#date_time ⇒ Object (readonly)
Returns the value of attribute date_time.
9 10 11 |
# File 'lib/natour/image.rb', line 9 def date_time @date_time end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/natour/image.rb', line 8 def path @path end |
Class Method Details
Instance Method Details
#autorotate ⇒ Object
29 30 31 |
# File 'lib/natour/image.rb', line 29 def autorotate Image.new(@path, @image.autorot) end |
#landscape? ⇒ Boolean
25 26 27 |
# File 'lib/natour/image.rb', line 25 def landscape? @landscape end |
#save_as(filename) ⇒ Object
43 44 45 46 |
# File 'lib/natour/image.rb', line 43 def save_as(filename) FileUtils.mkdir_p(Pathname(filename).dirname) StdoutUtils.suppress_output { @image.write_to_file(filename) } end |