Sha256: 9d59bb23a912945438d0712878f763791e18c1604071224d1174c29ec17d4751

Contents?: true

Size: 925 Bytes

Versions: 32

Compression:

Stored size: 925 Bytes

Contents

class HomeController < ApplicationController
  def index
    @image_id = params[:image] || 1
    @img = get_image

    @img_rotate = get_image do |options|
      options.resize("300x300")
      options.rotate "-45"
    end

    @img_negate = get_image do |options|
      options.resize("300x300")
      options.negate
    end

    @img_distort = get_image do |options|
      options.resize("300x300")
      options.distort("Perspective", "0,0,0,0 0,45,0,45 69,0,60,10 69,45,60,35")
    end
  end

  private

  def image_name
    image_names = [
      'cat1.jpg',
      'cat2.jpg',
      'cat3.jpg'
    ]
    image_name = image_names[@image_id.to_i - 1]
    puts params
    puts @image_id
    puts image_name

    "app/assets/images/#{image_name}"
  end

  def get_image(&block)
    puts image_name
    image = MiniMagick::Image.open(image_name)
    image.combine_options(&block)

    Base64.encode64(image.to_blob)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
rails_app_generator-0.3.6 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.5 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.4 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.3 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.2 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.1 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.3.0 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.43 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.42 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.41 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.40 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.39 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.38 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.37 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.36 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.35 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.34 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.33 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.32 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.31 after_templates/addons/mini_magick/app/controllers/home_controller.rb