lib/gnawrnip/screenshot.rb in gnawrnip-0.2.0 vs lib/gnawrnip/screenshot.rb in gnawrnip-0.2.1

- old
+ new

@@ -1,8 +1,9 @@ require 'tempfile' require 'time' require 'capybara' +require 'oily_png' module Gnawrnip class Screenshot class << self @@ -49,12 +50,10 @@ def need_resize? !Gnawrnip.max_frame_size.nil? end def resize(path) - require 'oily_png' - image = OilyPNG::Canvas.from_file(path) new_width, new_height = calculate_new_size(image.width, image.height) image.resample_bilinear!(new_width, new_height) image.save(path) @@ -65,15 +64,15 @@ # This size is keeping original aspect ratio. # # @return [Array] New width and height size. [width, height] # def calculate_new_size(width, height) - ratio = width / height + ratio = width.to_f / height.to_f target = Gnawrnip.max_frame_size return [width, height] if target > [width, height].max - if ratio < 0 + if ratio < 1 new_width = target * ratio new_height = target else new_width = target new_height = target / ratio