惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
L
LINUX DO - 热门话题
H
Hacker News: Front Page
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
Lohrmann on Cybersecurity
Cisco Talos Blog
Cisco Talos Blog
O
OpenAI News
S
Securelist
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
H
Heimdal Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
D
Docker
D
DataBreaches.Net
A
About on SuperTechFans
T
Tor Project blog
V
V2EX
G
Google Developers Blog
博客园 - Franky
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
I
InfoQ
H
Help Net Security
V2EX - 技术
V2EX - 技术
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security Affairs
SecWiki News
SecWiki News
The Register - Security
The Register - Security
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
小众软件
小众软件
B
Blog
T
Threatpost
P
Palo Alto Networks Blog
博客园 - 【当耐特】
L
LangChain Blog
AWS News Blog
AWS News Blog
月光博客
月光博客
宝玉的分享
宝玉的分享

开源实验室

一个月,纯VibeCoding,全平台云笔记APP|开源实验室 kymjs.com 借助 API 手写一个 Transformer 架构|开源实验室 PT 站规则扫盲|开源实验室 使用 RAGFlow 搭建一套 AI 客服知识库|开源实验室 终于搞定了,本地部署 RAGFlow|开源实验室 阿富汗-中亚最倒霉国家|开源实验室 【HarmonyOS】TheRouter 鸿蒙版新手入门|开源实验室 可能是 AGP8 编译最快的方案|开源实验室 NAS - 玩点有意思的|开源实验室 动态路由 TheRouter 的设计与实践|开源实验室 没错,TheRouter 是我写的|开源实验室 货拉拉 Android 模块化路由框架:TheRouter|开源实验室 菲律宾这国家到底怎么回事|开源实验室 印度的穆斯林王朝——德里苏丹|开源实验室 学历史有什么用|开源实验室 印度的列国时代大一统——孔雀王朝|开源实验室 印度列国时代的百家争鸣——沙门思潮|开源实验室 印度真是个神奇的国度——总章|开源实验室 某一天,中国真会超过美国吗?|开源实验室 基于 C++ 的 Android 协程设计|开源实验室 Gradle 6.X 上传 aar 到 Nexus 私服|开源实验室 自定义C/C++日志输出函数|开源实验室 扁平化管理,就是管理者的失职|开源实验室 再聊 Git Flow|开源实验室 Flutter 设置控件是否可见|开源实验室 Flutter 线性布局:Column 和 Row|开源实验室 Leader 的自我修养——学会预测|开源实验室 玩玩区块链——概念|开源实验室 一条电商 Android 工程化实践|开源实验室
开源一段 Mac 批量压缩图片的脚本|开源实验室
2020-03-17 · via 开源实验室

近日处理了一批照片,现在分享一下如何在mac平台进行图片批量处理。

0、安装 xCode 命令行工具,需要确定电脑上已经安装了 xCode,如果没有,自己去 AppStore 里面搜索就看到了。

打开终端,输入命令:

如果看到如下提示,表示已经安装了

xcode-select: error: command line tools are already installed, use "Software Update" to install updates  

1、安装brew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、使用 brew 安装 imagemagick

3、 去桌面新建一个 zip.sh 的文件,里面写入

#!/bin/bash
# 查找目录及子目录的图片文件(jpg,gif,png),将大于某值的图片进行压缩处理
# Config
folderPath=$1   # 图片目录路径

maxSize='200'    # 图片尺寸允许值
maxWidth=600   # 图片最大宽度
maxHeight=500  # 图片最大高度
quality=60      # 图片质量


# 压缩处理
# Param $folderPath 图片目录
function compress(){

    folderPath=$1

    if [ -d "$folderPath" ]; then

        for file in $(find "$folderPath" \( -name "*.jpg" -or -name "*.jpeg" -or -name "*.gif" -or -name "*.png" \) -type f -size +"$maxSize" ); do

            echo $file

            # 调用imagemagick resize图片
            $(convert -resize "$maxWidth"x"$maxHeight" "$file" -quality "$quality" -colorspace sRGB "$file")

        done

    else
        echo "$folderPath 不存在"
    fi
}

# 执行compress
compress "$folderPath"

exit 0

4、 给脚本执行权限

cd ~/Desktop

chmod a+x  zip.sh

5、 可以压缩图片了,下面命令的path替换成你要压缩的图片文件夹路径

cd ~/Desktop
./zip.sh  path