Sha256: 8fb108b2c254b24118216b0aefb1c289e9c0a85e2786964975a24b91e1c88ddf

Contents?: true

Size: 663 Bytes

Versions: 53

Compression:

Stored size: 663 Bytes

Contents

require_relative 'base'

module Udongo
  module ImageManipulation
    class ResizeToFit
      include Udongo::ImageManipulation::Base

      # Resize the image to fit within the specified dimensions while retaining
      # the original aspect ratio. The image may be shorter or narrower than
      # specified in the smaller dimension but will not be larger than the specified values.
      #
      def resize(path)
        img = MiniMagick::Image.open(@file)
        img.combine_options do |c|
          c.quality @options[:quality] if @options[:quality]
          c.resize "#{@width}x#{@height}"
        end

        img.write(path)
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
udongo-7.9.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.8.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.8.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.7.2 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.7.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.7.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.6.2 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.6.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.6.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.5.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.5.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.4.2 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.4.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.4.0 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.3.5 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.3.4 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.3.3 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.3.2 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.3.1 lib/udongo/image_manipulation/resize_to_fit.rb
udongo-7.2.1 lib/udongo/image_manipulation/resize_to_fit.rb