如何使用AppleScript为充满图像的文件夹生成html img标记?
我试图找到如何使用Automator或AppleScript从图像目录生成html如何使用AppleScript为充满图像的文件夹生成html img标记?,applescript,Applescript,我试图找到如何使用Automator或AppleScript从图像目录生成html标记,包括图像宽度和高度维度 为此,我需要: 选择多个文件,仅限于图像 制作一个循环,遍历每个文件 查找图像的维度 生成/连接字符串 我从来没有做过applescript,但我把它拼凑起来,主要是因为一个。欢迎提出建议 -- select multiple files, limited to images set filelist to choose file of type "public.image" with
标记,包括图像宽度和高度维度
为此,我需要:
我从来没有做过applescript,但我把它拼凑起来,主要是因为一个。欢迎提出建议
-- 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
——选择多个文件,仅限于图像
设置filelist以选择“public.image”类型的文件,并允许多选
将html设置为“”
--制作一个循环,遍历每个文件
对文件列表中的imagefile重复此操作
告诉应用程序“图像事件”
发射
将img设置为打开imagefile
--获取图像的尺寸
将img的维度复制到{W,H}
--构建/连接html字符串
将html设置为html&“
"
关闭img
结束语
结束重复
将剪贴板设置为html
显示对话框“html for”&文件列表长度&“复制到剪贴板的图像!”
html