Module: Sinicum::Imaging::Converter
- Included in:
- DefaultConverter, MaxSizeConverter, ResizeCropConverter
- Defined in:
- lib/sinicum/imaging/converter.rb
Overview
Collection of helper methods common to Converters
Constant Summary collapse
- CONVERTER_VERSION =
change to change Hash signature
"1"
- PNG_OPTIMIZER_SUFFIX =
"-fs8.png"
Instance Attribute Summary collapse
-
#document ⇒ Object
writeonly
Sets the attribute document.
Instance Method Summary collapse
-
#config_hash ⇒ String
Computes a standard hash for a converted image, consisting of ‘x`, `y`, `render_type` and `format`.
- #initialize(configuration) ⇒ Object
-
#interlace_option(x, y) ⇒ String
Returns the interlace command line option if an image is large enough (> 80px x 80px).
- #ratio(x, y) ⇒ Object
Instance Attribute Details
#document=(value) ⇒ Object (writeonly)
Sets the attribute document
11 12 13 |
# File 'lib/sinicum/imaging/converter.rb', line 11 def document=(value) @document = value end |
Instance Method Details
#config_hash ⇒ String
Computes a standard hash for a converted image, consisting of ‘x`, `y`, `render_type` and `format`.
25 26 27 28 29 |
# File 'lib/sinicum/imaging/converter.rb', line 25 def config_hash digest = Digest::MD5.hexdigest( "#{@x}-#{@y}-#{@hires_factor}-#{@render_type}-#{@format}-#{CONVERTER_VERSION}") digest end |
#initialize(configuration) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sinicum/imaging/converter.rb', line 13 def initialize(configuration) @x = configuration['x'] || '' @y = configuration['y'] || '' @render_type = configuration['render_type'] @hires_factor = configuration['hires_factor'] || 1.0 @configuration = configuration end |
#interlace_option(x, y) ⇒ String
Returns the interlace command line option if an image is large enough (> 80px x 80px)
37 38 39 |
# File 'lib/sinicum/imaging/converter.rb', line 37 def interlace_option(x, y) x.to_i * y.to_i > 80 * 80 ? "-interlace plane" : "" end |
#ratio(x, y) ⇒ Object
41 42 43 |
# File 'lib/sinicum/imaging/converter.rb', line 41 def ratio(x, y) x.to_f / y.to_f end |