class Catscope::App

Constants

EPS_MIN_PIXELS
TOP_DIR

Public Instance Methods

image_size(file_path) click to toggle source
# File lib/catscope/app.rb, line 78
def image_size(file_path)
  unless system("which identify >/dev/null 2>&1")
    return nil
  end

  identify_str = `identify "#{file_path}"`
  unless identify_str =~ /\s(\d+)x(\d+)\s/
    return nil
  end
  [$~[1].to_i, $~[2].to_i]
end
type_by_path(path) click to toggle source
# File lib/catscope/app.rb, line 56
def type_by_path(path)
  name = File.basename(path)
  if name =~ /\.([a-z0-9]+)$/
    ext = $~[1]
  else
    ext = nil
  end

  case ext
  when /^jpe?g$/i
    return "image/jpeg"
  when /^png$/i
    return "image/png"
  when /^(eps|svg)$/i # will be converted to png
    return "image/png"
  when /^pdf/i
    return "application/pdf"
  else
    return "text/plain"
  end
end