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.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vips/writer.rb', line 142

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.



132
133
134
# File 'lib/vips/writer.rb', line 132

def compression
  @compression
end

#formatObject

Returns the value of attribute format.



132
133
134
# File 'lib/vips/writer.rb', line 132

def format
  @format
end

#layoutObject

Returns the value of attribute layout.



132
133
134
# File 'lib/vips/writer.rb', line 132

def layout
  @layout
end

#multi_resObject

Returns the value of attribute multi_res.



132
133
134
# File 'lib/vips/writer.rb', line 132

def multi_res
  @multi_res
end

#predictorObject

Returns the value of attribute predictor.



132
133
134
# File 'lib/vips/writer.rb', line 132

def predictor
  @predictor
end

#qualityObject

Returns the value of attribute quality.



132
133
134
# File 'lib/vips/writer.rb', line 132

def quality
  @quality
end

#resolutionObject

Returns the value of attribute resolution.



132
133
134
# File 'lib/vips/writer.rb', line 132

def resolution
  @resolution
end

#resolution_unitsObject

Returns the value of attribute resolution_units.



132
133
134
# File 'lib/vips/writer.rb', line 132

def resolution_units
  @resolution_units
end

#tile_sizeObject

Returns the value of attribute tile_size.



132
133
134
# File 'lib/vips/writer.rb', line 132

def tile_size
  @tile_size
end

Instance Method Details

#compression_strObject



165
166
167
168
169
170
171
# File 'lib/vips/writer.rb', line 165

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

#layout_strObject



173
174
175
176
177
# File 'lib/vips/writer.rb', line 173

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

#resolution_strObject



179
180
181
182
183
# File 'lib/vips/writer.rb', line 179

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

#write(path) ⇒ Object



160
161
162
163
# File 'lib/vips/writer.rb', line 160

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