我有大量的图像,其中每个图像都需要删除Alpha。这在Preview应用程序中是可行的,但是我需要重复的时间太长了。
我听说过AppleScript,并在自动化过程中作了一些微弱的尝试,目前无济于事。
我正在使用类似的方法,然后开始重复操作,但是它只允许我循环浏览一个直接文件夹(同时我在菜单栏项目上遇到了麻烦)
set fl to files of folder POSIX file "/Users/user/Documents/" as alias list
但是我在文件夹中有多个文件夹,希望更改图像数量。文件夹结构如下:
用户/用户/文件夹/ ImagesRoot /
在ImagesRoot内部是3个文件夹和1个txt文件。我想专门选择2个名为“图标”和“屏幕截图”的文件夹。在“图标”中是5张图片。但是,“屏幕截图”包含3个子文件夹,每个子文件夹都有自己的5张图像。(可以称为“ Screensub 1,2,3”)
一旦收到该文件夹中的图像列表,该过程将类似于
tell application "Preview"
open the image file
open the file menu
open export...
untick alpha
press save
press replace
close window
end tell
Loop to next one
when looped through all in Icons folder, do all 5 images of each subfolder of screenshot folder
有人告诉我AppleScript是执行此操作的好方法,但是bash可能吗?但是,我有2%的applescript经验,也许还有4%的bash经验,并且不知道该如何处理。
任何建议或帮助将不胜感激。
谢谢
据我所知,即使启用AppleScripting,Preview也无法更改文档的Alpha值。在一个支持它的应用程序中,例如GraphicConverter,这是一个相当简单的任务:
on open imageFile
tell application "GraphicConverter 9"
open imageFile
tell window 1
set alpha to false
end tell
--save image as needed
end tell
end open
您可能会发现使用Automator更容易。您可能只需要将找到的每个子文件夹的“获取文件夹内容并重复”与“ Alpha通道”设置为“删除”结合使用。如果您需要排除某些文件,则“过滤器查找器项”将执行此操作。
但是,如果要使用预览,则可以使用系统事件。就像是:
on open imageFile
tell application "Preview"
open imageFile
activate
set filename to name of window 1
tell application "System Events"
tell process "Preview"
click menu item "Export…" of menu "File" of menu bar 1
tell sheet 1 of window 1
--rename file
set value of text field 1 to filename & " Alpha Removed"
--uncheck alpha channel
tell checkbox 1 of group 1
click
end tell
--save
click button "Save"
end tell
end tell
end tell
end tell
end open
如果选择辅助访问路线,您可能会发现Apple的签名应用程序帮助非常有用:http : //support.apple.com/kb/HT5914
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句