Class: VIPS::JPEGReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/vips/reader.rb,
ext/reader.c

Constant Summary collapse

SHRINK_FACTOR =
[1, 2, 4, 8]

Instance Attribute Summary collapse

Attributes inherited from Reader

#path

Instance Method Summary collapse

Methods inherited from Reader

read, recognized?

Methods included from Header

#band_fmt, #bands, #exif, #exif?, #get, #icc, #icc?, #n_elements, #set, #sizeof_element, #sizeof_line, #sizeof_pel, #x_offset, #x_res, #x_size, #y_offset, #y_res, #y_size

Constructor Details

#initialize(path, options = {}) ⇒ JPEGReader

Creates a jpeg image file reader.



76
77
78
79
80
81
82
83
84
# File 'lib/vips/reader.rb', line 76

def initialize(path, options={})
  @shrink_factor = 1
  @fail_on_warn = false

  self.shrink_factor = options[:shrink_factor] if options.has_key?(:shrink_factor)
  self.fail_on_warn = options[:fail_on_warn] if options.has_key?(:fail_on_warn)

  super path, options
end

Instance Attribute Details

#fail_on_warnObject

Returns the value of attribute fail_on_warn.



71
72
73
# File 'lib/vips/reader.rb', line 71

def fail_on_warn
  @fail_on_warn
end

#shrink_factorObject

Returns the value of attribute shrink_factor.



70
71
72
# File 'lib/vips/reader.rb', line 70

def shrink_factor
  @shrink_factor
end

Instance Method Details

#readObject

Read the jpeg file from disk and return a VIPS Image object.



87
88
89
90
91
92
# File 'lib/vips/reader.rb', line 87

def read
  str = "#{@path}:#{shrink_factor}"
  str << ",fail" if @fail_on_warn

  read_internal str
end