Sha256: 37303a01236b2832ee98ad34595d739dc7bbe8d7eab55a04a6d4434fe4deb131
Contents?: true
Size: 1.04 KB
Versions: 14
Compression:
Stored size: 1.04 KB
Contents
module PopulateMe class Variation < Struct.new :name, :ext, :job # 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 def initialize name, ext, job_as_proc=nil, &job_as_block super name, ext, job_as_proc||job_as_block end class << self 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 def default self.new_image_magick_job(:populate_me_thumb, :jpg, "-flatten -resize '400x230' -gravity center -extent 400x230") end end end end
Version data entries
14 entries across 14 versions & 1 rubygems