gpt4 book ai didi

image-processing - 如何在 Mac OS 中使用 Automator 批量缩放图像和白色填充

转载 作者:行者123 更新时间:2023-12-04 00:30:47 24 4
gpt4 key购买 nike

在 Mac OS 中使用 Automator 我正在尝试批量填充和缩放图像。我尝试将图像与填充一起批量缩放到特定大小。

  1. 如果我将整个文件夹拖放到 Automator 中则不起作用,仅适用于多个图像拖放。
  2. 对于填充,我在需要它是白色的地方得到了黑色

我已经尝试使用 Created Automator Application>Library>Photos>Pad Images

然后给 Canvas 尺寸然后在填充选项之前缩放图像

最佳答案

Automate Pad Image 操作使用黑色作为默认颜色填充 Canvas 。遗憾的是,没有办法修改此默认操作。

您可以做的是添加一个“运行 AppleScript”操作来调用 sips 命令行工具,以使用您想要的颜色填充图像。

为此,单击 Automator 边栏中的 Utilities Action 并添加“运行 AppleScript”操作。

用以下代码替换默认的 AppleScript 代码:

on run {input, parameters}  
repeat with this_file in input
set this_path to the quoted form of the POSIX path of this_file
do shell script "sips " & this_path & " -p 50 50 --padColor FFFFFF -i"
end repeat
return input
end run

-p 参数指定填充的宽度和高度。 --padColor 参数指定颜色。在这种情况下,颜色为白色。 FFFFFF 等于 RGB 颜色中的 255、255、255。

您可以在终端的命令行中键入“sip --help”,以查看该命令可以执行的所有很酷的操作。

关于image-processing - 如何在 Mac OS 中使用 Automator 批量缩放图像和白色填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28643466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com