我试图找到如何使用Automator或AppleScript从图像目录生成html <img>
标记,包括图像宽度和高度尺寸。
要做到这一点,我需要:
答案 0 :(得分:1)
我从来没有做过AppleScript,但将它拼凑在一起,主要归功于image events reference。建议欢迎。
-- select multiple files, limited to images
set filelist to choose file of type "public.image" with multiple selections allowed
set html to ""
-- make a loop that goes through each file
repeat with imagefile in filelist
tell application "Image Events"
launch
set img to open imagefile
-- get dimensions of image
copy the dimensions of img to {W, H}
-- build / concatenate html string
set html to html & "<img alt=\"\" src=\"" & name of imagefile & "\" width=\"" & W & "\" height=\"" & H & "\" />
"
close img
end tell
end repeat
set the clipboard to html
display dialog "html for " & length of filelist & " images copied to the clipboard!"
html