Sha256: 06a3422bc99be09d5edbe047ba61517442f14afe99b8a22a069c045e9a419d1b

Contents?: true

Size: 838 Bytes

Versions: 22

Compression:

Stored size: 838 Bytes

Contents

class HomeController < ApplicationController
  def index
    @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
    @variable ||= begin
      image_names = [
        'cat1.jpg',
        'cat2.jpg',
        'cat3.jpg'
      ]

      "app/assets/images/#{image_names.sample}"
    end
  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

22 entries across 22 versions & 1 rubygems

Version Path
rails_app_generator-0.2.18 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.17 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.16 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.15 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.14 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.13 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.12 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.11 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.10 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.9 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.8 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.7 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.6 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.5 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.4 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.3 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.2 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.1 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.2.0 after_templates/addons/mini_magick/app/controllers/home_controller.rb
rails_app_generator-0.1.28 after_templates/addons/mini_magick/app/controllers/home_controller.rb