Posted By

charlesroper on 03/19/07


Tagged

e-texteditor


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

gtcaz
webstic


Image dragcommand with dimensions


 / Published in: Ruby
 

  1. #!/usr/bin/env ruby
  2.  
  3. if File.exists?(ENV['TM_BUNDLE_SUPPORT'] + "/bin/sips")
  4. SIPS = ENV['TM_BUNDLE_SUPPORT'] + "/bin/sips"
  5. else
  6. SIPS = "sips"
  7. end
  8.  
  9. imgsrc = `cygpath -m \"#{ENV['TM_DROPPED_FILEPATH']}\"`.chomp
  10. imgdims = `\'#{SIPS}\' -g pixelWidth -g pixelHeight \'#{imgsrc}\'`
  11. imgdims = imgdims.split("\n").collect { |dim| dim.gsub(/\D/,"") }
  12. alt = File.basename(imgsrc, ".*").gsub("\\","")
  13. print "<img src=\"#{ENV['TM_DROPPED_FILE']}\" width=\"#{imgdims[0]}\" height=\"#{imgdims[1]}\" alt=\"#{alt}\" title=\"#{alt}\"#{ENV['TM_XHTML']}>"

Report this snippet  

You need to login to post a comment.