Sha256: 0283547514c9ea703cc6e877f140d61a981d04a8fbb268600b803b563e8b2168

Contents?: true

Size: 922 Bytes

Versions: 6

Compression:

Stored size: 922 Bytes

Contents

# typed: strict
# 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
  sig { returns(Integer) }
  attr_reader :height, :width

  sig { params(site: Jekyll::Site, collection: Jekyll::Collection, file: Jekyll::StaticFile, postfix: String, height: Integer, width: Integer).void }
  def initialize(site, collection, file, postfix, height, width)
    super(site, collection, file, file.name + postfix)

    @height = T.let(height, Integer)
    @width = T.let(width, Integer)
  end

  # instead of copying, renders the thumbnail
  sig { params(img: Magick::ImageList, path: String).void }
  def process_and_write(img, path)
    img.resize_to_fill!(height, width)
    img.write(path) {}
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cheesy-gallery-1.1.0 lib/cheesy-gallery/image_thumb.rb
cheesy-gallery-1.0.0 lib/cheesy-gallery/image_thumb.rb
cheesy-gallery-0.8.0 lib/cheesy-gallery/image_thumb.rb
cheesy-gallery-0.7.0 lib/cheesy-gallery/image_thumb.rb
cheesy-gallery-0.6.0 lib/cheesy-gallery/image_thumb.rb
cheesy-gallery-0.5.0 lib/cheesy-gallery/image_thumb.rb