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

recognized?, #x_size, #y_size

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.



36
37
38
39
40
41
42
# File 'lib/vips/reader.rb', line 36

def initialize(path, options={})
  @shrink_factor = options[:shrink_factor] || 1
  @fail_on_warn = options[:fail_on_warn] || false
  @sequential = options[:sequential] || false

  super path, options
end

Instance Attribute Details

#fail_on_warnObject

Returns the value of attribute fail_on_warn.



30
31
32
# File 'lib/vips/reader.rb', line 30

def fail_on_warn
  @fail_on_warn
end

#sequentialObject

Returns the value of attribute sequential.



31
32
33
# File 'lib/vips/reader.rb', line 31

def sequential
  @sequential
end

#shrink_factorObject

Returns the value of attribute shrink_factor.



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

def shrink_factor
  @shrink_factor
end

Instance Method Details

#readObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vips/reader.rb', line 44

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

  seq = 0
  if Vips.sequential_mode_supported?
    str << "," 
    str << "sequential" if @sequential
    seq = 1
  end

  @_im = read_internal str, seq
end