当我运行苹果自动自动处理器, 简单地剪切图像的大小时, 自动处理器也会降低文件的质量( jpg), 使文件变得模糊不清 。
我怎样才能阻止这一切呢?有我能够控制的设置吗?
<强>编辑: 强>
或者还有其他工具可以做同样的工作,但不影响图像质量?
当我运行苹果自动自动处理器, 简单地剪切图像的大小时, 自动处理器也会降低文件的质量( jpg), 使文件变得模糊不清 。
我怎样才能阻止这一切呢?有我能够控制的设置吗?
<强>编辑: 强>
或者还有其他工具可以做同样的工作,但不影响图像质量?
自动采集器的“作物图像”和“比例图像”操作没有质量设置 — — 与自动处理器通常的情况一样,简单胜过配置。 然而,还有另一种方法可以访问“Corem>Coreimage Scripable图像处理系统 ,它使得图像处理功能能够提供给
sips
utility. You can fiddle with the most minute settings using this, but as it is a bit arcane in handling, you might be better served with the second way,crop
和 scale
命令,在保存为 JPEG 时指定压缩级别选项
save <image> as JPEG with compression level (low|medium|high)
使用“ Run ApplesScript” 动作代替您的“ rop” / “ 比例” 动作, 将图像事件命令以 < code> tell 应用程序“ 图像事件” code> 块包装, 您应该被设置。 例如, 将图像缩放到一半大小, 并保存为质量最佳的 JPEG, 重写原件 :
on run {input, parameters}
set output to {}
repeat with aPath in input
tell application "Image Events"
set aPicture to open aPath
try
scale aPicture by factor 0.5
set end of output to save aPicture as JPEG with compression level low
on error errorMessage
log errorMessage
end try
close aPicture
end tell
end repeat
return output -- next action processes edited files.
end run
- 对于其他尺度,相应调整系数(1 = 100%, 5 = 50%, 25 = 25 = 25 等); 对于作物, 将 < code> 比例 apicture 替换为 X code>, 代号为 < code> rop aicture to {width, high\/ / code>.Mac OS X Automation 具有良好的教义,说明两者的使用都 < href=" "http://www. macosxxultomation.com/ appletr= " noreferrer" > crop 。
如果您想要对 JPEG 压缩量有更细的控制, 正如 kopischke 所说, 您将不得不使用 < code> sips code > 工具, 它可以用于 shell 脚本中。 这里您在 Automator 中要怎么做 :
首先获得文件和压缩设置 :
"https://i.sstatic.net/09JtO.png" alt="将文件和压缩设置粘贴到 Automator 中的空格脚本"/ >
<强度> 询问文本 强度> 动作不应接受任何输入( 右键点击它, 选择“ Ignore implement ” )。
确保变量 < / strong > 动作的第一个 < get > get value 不接受任何输入( 右键点击它们, 选择 " Ignore impport " ), 并且第二个 < general > Get value of vice < / strong > 会从第一个输入。 这将创建一个数组, 然后传递到 shell 脚本。 数组的第一个项目是给自动脚本的压缩级别。 第二个是脚本将执行 < code> sips 命令的文件列表 。
在 < strong > Run Shell 脚本 动作的顶端选项中,选择“/bin/bash”作为壳牌,并选择“ 作为参数”用于传送输入。然后粘贴此代码 :
itemNumber=0
compressionLevel=0
for file in "$@"
do
if [ "$itemNumber" = "0" ]; then
compressionLevel=$file
else
echo "Processing $file"
filename="$file"
sips -s format jpeg -s formatOptions $compressionLevel "$file" --out "${filename%.*}.jpg"
fi
((itemNumber=itemNumber+1))
done
((itemNumber=itemNumber-1))
osascript -e "tell app "Automator" to display dialog "${itemNumber} Files Converted" buttons {"OK"}"
如果您点击底部的“ 坚固” Results 坚固”, 它会告诉您它正在处理的文件 。 玩得开心的压缩!
20中的评论 20
I changed the script into a quick action, without any prompts (for compression as well as confirmation). It duplicates the file and renames the original version to _original. I also included nyam s solution for the space problem. You can download the workflow file here: http://mobilejournalism.blog/files/Compress%2080%20percent.workflow.zip (file is zipped, because otherwise it will be recognized as a folder instead of workflow file)
希望这对任何寻求这种解决办法的人都有用(就像我一小时前所做的那样)。
Eric s code is just brilliant. Can get most of the jobs done. but if the image s filename contains space, this workflow will not work.(due to space will break the shell script when processing sips.) There is a simple solution for this: add "Rename Finder Item" in this workflow. replace spaces with "_" or anything you like. then, it s good to go.
17岁的评论
To avoid "space" problem, it s smarter to change IFS than renaming. Back up current IFS and change it to only. And restore original IFS after the processing loop.
ORG_IFS=$IFS
IFS=$
for file in $@
do
...
done
IFS=$ORG_IFS
I was wondering if there was a way in Automator to use Applescript code to get the extension of a file, and if it equals a specific extension (e.g. .pdf or .rtf) move to a specific folder for that ...
Do Automator variable persist between executions of a workflow? If a variable is set during the execution of a workflow, can I get the last value assigned to a variable, once the workflow is executed ...
Im trying to use a variable in Automator to save images into a specific folder. Strangely when you create a new folder and you use a variable, it allows you to set the base path... but if you try to "...
Just wondering if there is a way to batch edit pdf documents and set the "Page Layout" and "Magnification" attribute of a document so that they all the documents are displayed the same way if you open ...
Ok, so I have an excel spreadsheet that contains data that I would like to copy directly into an SQLite db using Menial Base, a db editor. I have tried a number of different methods such as trying to ...
I m using a Mac, OSX 10.6 and I have a function in a desktop application that I want to automate. Manually I press Command+R wait for the application to read some data form a physical device for 1 ...
When I create a Automator action in XCode using Bash, all files and folder paths are printed to stdin. How do I get the content of those files? Whatever I try, I only get the filename in the output. ...
I have an automator script that I d like to run on a folder. I want the script to take each file in the folder and run my shell command on it. Automator is set to pass input to stdin, but I don t ...