aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2009-08-28 16:36:25 -0400
committerRalph Amissah <ralph@amissah.com>2009-08-28 16:36:25 -0400
commit5bf55b399d8c109ebe906e8c9f70b9e20a5f1156 (patch)
treed90fa07a1d4a3c1b316744faaefb4070e4b7907e /lib
parentdebian/changelog sisu (0.71.2-1) unstable; urgency=low (diff)
parentdal images, where rmagick cannot be loaded use imagemagick directly if available (diff)
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v1/dal_images.rb15
1 files changed, 11 insertions, 4 deletions
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}")