如果需要,我需要一种简单且免费的方法来调整图像大小并执行批处理作业。免费的图像处理软件比它应该的要难用。
Answers:
正如LifeHacker指出的那样,以下命令将非常轻松地完成此操作:
sips -Z 640 *.jpg
引用他们的解释:
“那么发生了什么?好吧,“ sips”是正在使用的命令,-Z告诉它保持图像的宽高比。“ 640”是要使用的最大高度和宽度,“ *。jpg”指示计算机缩小尺寸每张以.jpg结尾的图片都非常简单,并且可以非常迅速地缩小图片。如果还要保留较大的图片,请务必先进行复制。”
资料来源:http : //lifehacker.com/5962420/batch-resize-images-quickly-in-the-os-x-terminal
homebrew install imagemagick
conda install -c conda-forge imagemagick
这是一个脚本,用于sips
递归地调整给定文件夹(及其子文件夹)中所有图像的大小,并将调整大小后的图像resized
放置在与该图像相同的树级别的文件夹中:https : //gist.github.com/ lopespm / 893f323a04fcc59466d7
#!/bin/bash
# This script resizes all the images it finds in a folder (and its subfolders) and resizes them
# The resized image is placed in the /resized folder which will reside in the same directory as the image
#
# Usage: > ./batch_resize.sh
initial_folder="/your/images/folder" # You can use "." to target the folder in which you are running the script for example
resized_folder_name="resized"
all_images=$(find -E $initial_folder -iregex ".*\.(jpg|gif|png|jpeg)")
while read -r image_full_path; do
filename=$(basename "$image_full_path");
source_folder=$(dirname "$image_full_path");
destination_folder=$source_folder"/"$resized_folder_name"/";
destination_full_path=$destination_folder$filename;
if [ ! -z "$image_full_path" -a "$image_full_path" != " " ] &&
# Do not resize images inside a folder that was already resized
[ "$(basename "$source_folder")" != "$resized_folder_name" ]; then
mkdir "$destination_folder";
sips -Z 700 "$image_full_path" --out "$destination_full_path";
fi
done <<< "$all_images"
另外@grepit回复
正确的语法是:
magick mogrify -resize 60% *
而且您需要安装ImageMagick,最简单的方法是使用自制软件:
brew install imagemagick
Error: Cannot do --extractTag on file error
尝试在High Sierra上转换png时得到提示:-(