Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created October 9, 2012 17:45
Show Gist options
  • Save ttscoff/3860278 to your computer and use it in GitHub Desktop.
Save ttscoff/3860278 to your computer and use it in GitHub Desktop.
Create image tag using sips
#!/usr/bin/ruby
img = ARGV[0]
width = %x{sips -g pixelWidth #{img}|tail -n 1}.gsub(/pixelWidth: /,'').strip
height = %x{sips -g pixelHeight #{img}|tail -n 1}.gsub(/pixelHeight: /,'').strip
output = %Q{<img src="#{File.basename(img)}" style="width:#{width}px;height:#{height}px">}
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment