Sha256: 3997d5ff7b07518858754528bc1c1ed3d1ddea42b6d19bdf629ef5251bff1822

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

require 'rmagick'
require 'cheesy-gallery/base_image_file'

# This StaticFile subclass represents thumbnail images for each image. On `write()` it renders a 150x150 center crop of the source
class CheesyGallery::ImageThumb < CheesyGallery::BaseImageFile
  attr_reader :height, :width

  def initialize(site, collection, file, postfix, height, width)
    super(site, collection, file, file.name + postfix)

    @height = height
    @width = width
  end

  # instead of copying, renders the thumbnail
  def process_and_write(img, path)
    img.resize_to_fill!(height, width)
    img.write(path)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cheesy-gallery-1.1.1 lib/cheesy-gallery/image_thumb.rb