Sha256: f4fb6b2781ac77bf62b92b0deb5a9c6d235b6d2918e07d465478bd92856af361
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'digest/sha1' module Prawn module Images # Base class for image info objects # @abstract class Image # @group Extension API # Calculate the final image dimensions from provided options. # @private def calc_image_dimensions(options) w = options[:width] || width h = options[:height] || height if options[:width] && !options[:height] wp = w / Float(width) w = width * wp h = height * wp elsif options[:height] && !options[:width] hp = h / Float(height) w = width * hp h = height * hp elsif options[:scale] w = width * options[:scale] h = height * options[:scale] elsif options[:fit] bw, bh = options[:fit] bp = bw / Float(bh) ip = width / Float(height) if ip > bp w = bw h = bw / ip else h = bh w = bh * ip end end self.scaled_width = w self.scaled_height = h [w, h] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.5.0 | lib/prawn/images/image.rb |