Sha256: fa501df9260f40b51deddb71d05459269214c1d2b20cb49a1f5d711dd19ee717

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

module Nanoc2::BinaryFilters

  class ImageScienceThumbnail < Nanoc2::BinaryFilter

    identifier :image_science_thumbnail

    def run(file)
      require 'image_science'

      # Get temporary file path
      tmp_file = Tempfile.new('filter')
      tmp_path = tmp_file.path
      tmp_file.close

      # Create thumbnail
      ImageScience.with_image(file.path) do |img|
        img.thumbnail(@asset_rep.thumbnail_size || 150) do |thumbnail|
          thumbnail.save(tmp_path)
        end
      end

      # Return thumbnail file
      File.open(tmp_path)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc2-2.2.3 lib/nanoc2/binary_filters/image_science_thumbnail.rb