class PopulateMe::Variation
Public Class Methods
default()
click to toggle source
# File lib/populate_me/variation.rb, line 29 def default self.new_image_magick_job(:populate_me_thumb, :jpg, "-flatten -resize '400x230' -gravity center -extent 400x230") end
new(name, ext, job_as_proc=nil, &job_as_block)
click to toggle source
Simple class to deal with variations of an attachment Mainly variation of images using ImageMagick but it could be anything else like creating the pdf version of a text file
Calls superclass method
# File lib/populate_me/variation.rb, line 10 def initialize name, ext, job_as_proc=nil, &job_as_block super name, ext, job_as_proc||job_as_block end
new_image_magick_job(name, ext, convert_string, options={})
click to toggle source
# File lib/populate_me/variation.rb, line 16 def new_image_magick_job name, ext, convert_string, options={} o = { strip: true, progressive: true, }.merge(options) defaults = "" defaults << "-strip " if o[:strip] defaults << "-interlace Plane " if o[:progressive] and [:jpg,:jpeg].include?(ext.to_sym) job = lambda{ |src,dst| Kernel.system "convert \"#{src}\" #{defaults}#{convert_string} \"#{dst}\"" } self.new name, ext, job end