From a3e1f8bf328199b15abad680e0f7abbf284d8cd1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 28 Aug 2009 16:34:10 -0400 Subject: dal images, where rmagick cannot be loaded use imagemagick directly if available --- lib/sisu/v1/dal_images.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/sisu/v1/dal_images.rb') diff --git a/lib/sisu/v1/dal_images.rb b/lib/sisu/v1/dal_images.rb index 67893025..1882aea5 100644 --- a/lib/sisu/v1/dal_images.rb +++ b/lib/sisu/v1/dal_images.rb @@ -67,7 +67,11 @@ module SiSU_images @rmgk=false imagemagick_=SiSU_Env::Info_settings.new.program?('rmagick') if imagemagick_ - @rmgk=SiSU_Env::Load.new('RMagick').prog + begin + @rmgk=SiSU_Env::Load.new('RMagick').prog + rescue + @rmgk=false + end else if @md.cmd =~/[vVM]/ tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') @@ -81,6 +85,7 @@ module SiSU_images m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ if imagemagick_ imgs=para.scan(m).flatten + img_col=img_row=nil images=imgs.each do |image| dir=SiSU_Env::Info_env.new(@md.fns) path_image=[dir.path.image_source_local_tex,dir.path.image_source_remote_tex,dir.path.image_source_tex] @@ -101,19 +106,21 @@ module SiSU_images img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2] img_col,img_row=img_col.to_i,img_row.to_i end + row=(img && defined? img.rows) ? img.rows : img_row + col=(img && defined? img.columns) ? img.columns : img_col if img_col > img_row #landscape if img_col> 640 #480 img_col=640 #480 - img_row=((1.00*img_col/img.columns)*img.rows).round + img_row=((1.00*img_col/col)*row).round end else #portrait if img_col> 640 #480 img_col=640 #480 - img_row=((1.00*img_col/img.columns)*img.rows).round + img_row=((1.00*img_col/col)*row).round end if img_row > 640 img_row=640 - img_col=((1.00*img_row/img.rows)*img.columns).round + img_col=((1.00*img_row/row)*col).round end end para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") -- cgit v1.2.3