Module: RScale::Processor
- Defined in:
- lib/rscale/geometry.rb,
lib/rscale/processor.rb
Defined Under Namespace
Classes: Convert, Geometry
Constant Summary
collapse
- @@sharp_level =
[0.5, 0.5]
- @@silent =
true
Class Method Summary
collapse
Class Method Details
.process(file_in, file_out, opts = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rscale/processor.rb', line 31
def self.process(file_in, file_out, opts={})
src = Geometry.from_file(file_in)
dst = Geometry.parse(opts[:size])
sz = dst.ratio > src.ratio ? "#{dst.width}x" : "x#{dst.height}"
opts[:crop] = true unless opts.key?(:crop)
convert = Convert.new(file_in, file_out) do |c|
c.add(:resize, sz)
c.add(:gravity, 'Center')
c.add(:crop, "#{dst}+0+0") if opts[:crop]
c.add(:sharpen, "#{@@sharp_level.first}{#{@@sharp_level.last}}'") if opts.key?(:sharp)
c.add(:quality, "#{opts[:q]}") if opts.key?(:q)
c.execute
end
return File.exists?(file_out)
end
|