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.



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

def initialize(path, options={})
  @shrink_factor = 1
  @fail_on_warn = false
  @sequential = 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)
  self.sequential = options[:sequential] if options.has_key?(:sequential)

  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

#sequentialObject

Returns the value of attribute sequential.



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

def sequential
  @sequential
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.



90
91
92
93
94
95
96
97
98
# File 'lib/vips/reader.rb', line 90

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

  read_internal str
end