/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env ruby if File.exists?(ENV['TM_BUNDLE_SUPPORT'] + "/bin/sips") SIPS = ENV['TM_BUNDLE_SUPPORT'] + "/bin/sips" else SIPS = "sips" end imgsrc = `cygpath -m \"#{ENV['TM_DROPPED_FILEPATH']}\"`.chomp imgdims = `\'#{SIPS}\' -g pixelWidth -g pixelHeight \'#{imgsrc}\'` imgdims = imgdims.split("\n").collect { |dim| dim.gsub(/\D/,"") } alt = File.basename(imgsrc, ".*").gsub("\\","") print "<img src=\"#{ENV['TM_DROPPED_FILE']}\" width=\"#{imgdims[0]}\" height=\"#{imgdims[1]}\" alt=\"#{alt}\" title=\"#{alt}\"#{ENV['TM_XHTML']}>"