Skip to content

Instantly share code, notes, and snippets.

@ts
Created November 20, 2013 20:02
Show Gist options
  • Save ts/7570033 to your computer and use it in GitHub Desktop.
Save ts/7570033 to your computer and use it in GitHub Desktop.
Copy <img /> tag with dimensnions
set this_file to choose file without invisibles
try
tell application "Image Events"
-- start the Image Events application
launch
-- open the image file
set this_image to open this_file
-- get dimensions of the image
copy dimensions of this_image to {W, H}
set file_name to name of this_image
-- purge the open image data
close this_image
end tell
set the clipboard to "<img src=\"" & file_name & "\" width=\"" & W & "\" height=\"" & H & "\" />"
on error error_message
display dialog error_message
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment