diff options
Diffstat (limited to 'lib/sisu/v1')
-rw-r--r-- | lib/sisu/v1/dal_images.rb | 27 |
1 files changed, 21 insertions, 6 deletions
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 |