如果需要,我需要一种简单且免费的方式来调整图像大小并执行批处理作业。免费的图像处理软件比它应该使用起来更加棘手。
答案 0 :(得分:101)
正如LifeHacker所指出的,以下命令将非常容易地做到这一点:
sips -Z 640 *.jpg
引用他们的解释:
“那么发生了什么?好吧,”sips“是正在使用的命令,-Z告诉它保持图像的纵横比。”640“是要使用的最大高度和宽度,”* .jpg“指示你计算机缩小每个以.jpg结尾的图像。它非常简单并且可以非常快速地缩小图像。如果你想保留更大的尺寸,请务必先复制一份。“
来源:http://lifehacker.com/5962420/batch-resize-images-quickly-in-the-os-x-terminal
答案 1 :(得分:11)
答案 2 :(得分:5)
这是使用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"
答案 3 :(得分:3)
另外@grepit回复
正确的语法是:
magick mogrify -resize 60% *
您需要安装ImageMagick,最简单的方法是使用自制软件:
brew install imagemagick
答案 4 :(得分:2)
以前的答案是正确的,您也可以使用mogrify。例如,如果要将目录中许多图像的大小减少60%,则可以使用以下命令:
当然,在使用此命令之前,总是将图像备份到另一个目录中。
mogrify -resize 60% *
答案 5 :(得分:2)
itunesconnect的魔术技巧:)
mkdir ./iPhone5-5-Portrait
sips -z 2208 1242 *.jpg -s formatOptions 70 --out ./iPhone5-5-Portrait
sips -z 2208 1242 *.png --out ./iPhone5-5-Portrait