class Jekyll::Assets::Plugins::MiniMagick
Public Instance Methods
process()
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 20 def process img = ::MiniMagick::Image.new(@file) magick_format(img) if @args[:magick][:format] img.combine_options do |c| @args[:magick].keys.reject { |k| k == :format }.each do |k| m = "magick_#{k}" if respond_to?(m, true) method(m).arity == 2 ? send(m, img, c) : send(m, c) end end end @file ensure img&.destroy! end
runners()
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 38 def runners private_methods(true).select do |v| v =~ %r!^magick_! && v != :magick_format end end
Private Instance Methods
magick_background(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 63 def magick_background(cmd) if @args[:magick].key?(:background) cmd.background @args[:magick][:background] end end
magick_compress(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 70 def magick_compress(cmd) if @args[:magick].key?(:compress) cmd.compress @args[:magick][:compress] end end
magick_crop(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 105 def magick_crop(cmd) if @args[:magick].key?(:crop) cmd.crop @args[:magick][:crop] end end
magick_flip(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 98 def magick_flip(cmd) if @args[:magick].key?(:flip) cmd.flip @args[:magick][:flip] end end
magick_format(img)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 45 def magick_format(img) format = ".#{@args[:magick][:format].sub(%r!^\.!, '')}" ext = @env.mime_exts.find { |k, v| k == format || v == format } return unless ext ext, type = ext raise SameType, type if type == asset.content_type img.format(ext.sub(".", "")) end
magick_gravity(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 112 def magick_gravity(cmd) if @args[:magick].key?(:gravity) cmd.gravity @args[:magick][:gravity] end end
magick_preset_resize(img, cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 124 def magick_preset_resize(img, cmd) # rubocop:disable Metrics/LineLength width, height = img.width * 2, img.height * 2 if @args[:magick].key?(:double) width, height = img.width / 2, img.height / 2 if @args[:magick].key?(:half) cmd.resize "#{width}x#{height}" if width && height end
magick_quality(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 77 def magick_quality(cmd) if @args[:magick].key?(:quality) cmd.quality @args[:magick][:quality] end end
magick_resize(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 84 def magick_resize(cmd) if @args[:magick].key?(:resize) cmd.resize @args[:magick][:resize] end end
magick_rotate(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 91 def magick_rotate(cmd) if @args[:magick].key?(:rotate) cmd.rotate @args[:magick][:rotate] end end
magick_strip(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 119 def magick_strip(cmd) cmd.strip end
magick_transparency(cmd)
click to toggle source
# File lib/jekyll/assets/plugins/proxy/magick.rb, line 56 def magick_transparency(cmd) if @args[:magick][:transparency] cmd.transparency @args[:magick][:transparency] end end