Class: VIPS::TIFFWriter

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

Constant Summary collapse

COMPRESSION =
[:none, :jpeg, :deflate, :packbits, :ccittfax4, :lzw]
PREDICTOR =
[:none, :horizontal_differencing, :floating_point]
LAYOUT =
[:strip, :tile]
MULTI_RES =
[:flat, :pyramid]
FORMAT =
[:manybit, :onebit]
RESOLUTION_UNITS =
[:cm, :inch]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Writer

#exif=, #icc=, #image, #remove_exif, #remove_icc

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(image, options = {}) ⇒ TIFFWriter

Returns a new instance of TIFFWriter.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/vips/writer.rb', line 119

def initialize(image, options={})
  super image

  @compression = :none
  @quality = 75
  @predictor = :none
  @layout = :strip
  @tile_size = [128, 128]
  @multi_res = :flat
  @format = :manybit
  @resolution_units = :cm

  [ :compression, :layout, :multi_res, :format, :resolution_units,
    :resolution, :predictor, :quality, :tile_size ].each do |att|
    self.send "#{att}=".to_sym, options[att] if options.has_key?(att)
  end
end

Instance Attribute Details

#compressionObject

Returns the value of attribute compression.



109
110
111
# File 'lib/vips/writer.rb', line 109

def compression
  @compression
end

#formatObject

Returns the value of attribute format.



109
110
111
# File 'lib/vips/writer.rb', line 109

def format
  @format
end

#layoutObject

Returns the value of attribute layout.



109
110
111
# File 'lib/vips/writer.rb', line 109

def layout
  @layout
end

#multi_resObject

Returns the value of attribute multi_res.



109
110
111
# File 'lib/vips/writer.rb', line 109

def multi_res
  @multi_res
end

#predictorObject

Returns the value of attribute predictor.



109
110
111
# File 'lib/vips/writer.rb', line 109

def predictor
  @predictor
end

#qualityObject

Returns the value of attribute quality.



109
110
111
# File 'lib/vips/writer.rb', line 109

def quality
  @quality
end

#resolutionObject

Returns the value of attribute resolution.



109
110
111
# File 'lib/vips/writer.rb', line 109

def resolution
  @resolution
end

#resolution_unitsObject

Returns the value of attribute resolution_units.



109
110
111
# File 'lib/vips/writer.rb', line 109

def resolution_units
  @resolution_units
end

#tile_sizeObject

Returns the value of attribute tile_size.



109
110
111
# File 'lib/vips/writer.rb', line 109

def tile_size
  @tile_size
end

Instance Method Details

#compression_strObject



142
143
144
145
146
147
148
# File 'lib/vips/writer.rb', line 142

def compression_str
  case @compression
  when :jpeg then "#{@compression}:#{@quality}"
  when :lzw, :deflate then "#{@compression}:#{@predictor}"
  else @compression
  end
end

#layout_strObject



150
151
152
153
154
# File 'lib/vips/writer.rb', line 150

def layout_str
  s = @layout
  s << ":#{@tile_size.join 'x'}" if @layout == :tile
  s
end

#resolution_strObject



156
157
158
159
160
# File 'lib/vips/writer.rb', line 156

def resolution_str
  s = "res_#{@resolution_units}"
  s << ":#{@resolution.join 'x'}" if @resolution
  s
end

#write(path) ⇒ Object



137
138
139
140
# File 'lib/vips/writer.rb', line 137

def write(path)
  opts = [compression_str, layout_str, @multi_res, @format, resolution_str].join ','
  write_internal "#{path}:#{opts}"
end