From ca8077dec8f560d2e317776a1839a00e0ac92ac9 Mon Sep 17 00:00:00 2001 From: Andrew Davidson Date: Thu, 29 Oct 2009 20:44:01 -0700 Subject: [PATCH] debugged the screenshot helper, should work for all conditions and has default height and width as a backup for an unforeseen case --- app/helpers/screenshot_helper.rb | 25 ++++++++++++++++--------- app/views/screenshot/single.html.erb | 6 +++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/helpers/screenshot_helper.rb b/app/helpers/screenshot_helper.rb index 185ef68..6fc1c03 100644 --- a/app/helpers/screenshot_helper.rb +++ b/app/helpers/screenshot_helper.rb @@ -9,21 +9,28 @@ module ScreenshotHelper ## Outputs: ## Size array of 'width' and 'height' ## - size = nil + if (fwidth >= fheight) then - if (fwidth[0] >= max) then - size[width] = max + if (fwidth >= max) then + width = max + height = ((fheight / fwidth.to_f) * max).to_i else - size[width] = fwidth + width = fwidth + height = fheight end - else - if (fheight >= max) then - size[height] = max - size[width] = (( fwidth / fheight.to_f ) * max).to_i + elsif (fheight > fwidth) then + if (fheight > max) then + height = max + width = (( fwidth / fheight.to_f ) * max).to_i else - size[height] = fheight + height = fheight + width = fwidth end + else + width = fwidth + height = fheight end + return [width, height] end end diff --git a/app/views/screenshot/single.html.erb b/app/views/screenshot/single.html.erb index 780bae9..34c11d7 100644 --- a/app/views/screenshot/single.html.erb +++ b/app/views/screenshot/single.html.erb @@ -1,7 +1,7 @@ -<% size = size_calc(@fsize[0], @fsize[1], 500) %> +<% size = size_calc(@fsize[0], @fsize[1], 600) %>
-
- <%= image_tag @fpath , :width => size[width] , :height => size[height] %> +
+ <%= image_tag @fpath , :width => size[0] , :height => size[1] %>
\ No newline at end of file