Sha256: 4050b7f15f30e397d0be144d458bb6b9610d4beeb9c23f0c8384ed7890d909dd
Contents?: true
Size: 862 Bytes
Versions: 6
Compression:
Stored size: 862 Bytes
Contents
module Attachs class Console class << self def find_content_type(path) run "file -Ib '#{path}'" do |output| output.split(';').first end end def find_dimensions(path) run "gm identify -format %wx%h '#{path}'" do |output| output.split('x').map &:to_i end end def convert(source_path, destination_path, options=nil) run "gm convert '#{source_path}' #{options} '#{destination_path}'".squeeze(' ') end private def run(cmd) Rails.logger.info "Running: #{cmd}" stdout, stderr, status = Open3.capture3(cmd) if status.success? output = stdout.strip if block_given? yield output else output end else false end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems