From 39e72afa0efa19a0dd94cff40ecd465162c3d379 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 24 Jul 2009 15:40:17 -0400 Subject: dal images, if no rmagick, system call imagemagick directly if available --- lib/sisu/v1/dal_images.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v1/dal_images.rb b/lib/sisu/v1/dal_images.rb index 621ac986..67893025 100644 --- a/lib/sisu/v1/dal_images.rb +++ b/lib/sisu/v1/dal_images.rb @@ -65,16 +65,21 @@ module SiSU_images data=@data tuned_file=[] @rmgk=false - if SiSU_Env::Info_settings.new.program?('rmagick'); @rmgk=SiSU_Env::Load.new('RMagick').prog - else tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') - tell.warn if @md.cmd =~/[vVM]/ + imagemagick_=SiSU_Env::Info_settings.new.program?('rmagick') + if imagemagick_ + @rmgk=SiSU_Env::Load.new('RMagick').prog + else + if @md.cmd =~/[vVM]/ + tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') + tell.warn + end end data.each do |para| para.strip! if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ if para !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ - if @rmgk + if imagemagick_ imgs=para.scan(m).flatten images=imgs.each do |image| dir=SiSU_Env::Info_env.new(@md.fns) @@ -84,8 +89,18 @@ module SiSU_images break if FileTest.exist?("#{image_path}/#{image}") end if FileTest.exist?("#{image_path}/#{image}") - img=Magick::ImageList.new("#{image_path}/#{image}") - img_col,img_row=img.columns,img.rows + if @rmgk + img=Magick::ImageList.new("#{image_path}/#{image}") + img_col,img_row=img.columns,img.rows + else + if @md.cmd =~/[vVM]/ + tell=SiSU_Screen::Ansi.new(@md.cmd,'RMagick not present, will attempt to use imagemagick (identify) directly') + tell.warn + end + imgsys=`identify #{image_path}/#{image}`.strip #system call + 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 if img_col > img_row #landscape if img_col> 640 #480 img_col=640 #480 -- cgit v1.2.3