Sha256: 4c9793553903bec855e971a2ca3e529cbf9b8644ce670677f13037b991d5dec2
Contents?: true
Size: 1.5 KB
Versions: 29
Compression:
Stored size: 1.5 KB
Contents
module Locomotive module Steam module Liquid module Filters module Resize # Optional args include: # quality: <number> compress image # auto_orient: <true|false> fix EXIF orientation issues # strip: <true|false> remove extra possibly unnecessary metadata # progressive: <true|false> make JPEG progressive # optimize: <number> shortcut to quality: and also applies strip and progressive # filters: <string> access to any ImageMagick arguments def resize(input, resize_string, *args) args ||= {} options = [] args.flatten.each do |arg| arg.each do |k, v| options << case k.to_sym when :quality "-quality #{v}" when :optimize # Shortcut helper to set quality, progressive and strip "-quality #{v} -strip -interlace Plane" when :auto_orient "-auto-orient" if v when :strip "-strip" if v when :progressive "-interlace Plane" if v when :filters v else next end end end @context.registers[:services].image_resizer.resize(input, resize_string, options.join(' ')) end end ::Liquid::Template.register_filter(Resize) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems