sips命令行圖片處理工具
sips是什么邓馒?
通過sips --help 查看到sips的簡介:sips - scriptable image processing system.
This tool is used to query or modify raster image files and ColorSync ICC profiles.
Its functionality can also be used through the "Image Events" AppleScript suite.
查看sips是否存在
which sips
/usr/bin/sips
sips的用法
? sips --help
sips - scriptable image processing system.
This tool is used to query or modify raster image files and ColorSync ICC profiles.
Its functionality can also be used through the "Image Events" AppleScript suite.
Usages:
sips [image-functions] imagefile ...
sips [profile-functions] profile ...
Profile query functions:
-g, --getProperty key
-X, --extractTag tag tagFile
--verify
-1, --oneLine
Image query functions:
-g, --getProperty key
-x, --extractProfile profile
-1, --oneLine
Profile modification functions:
-s, --setProperty key value
-d, --deleteProperty key
--deleteTag tag
--copyTag srcTag dstTag
--loadTag tag tagFile
--repair
-o, --out file-or-directory
Image modification functions:
-s, --setProperty key value
-d, --deleteProperty key
-e, --embedProfile profile
-E, --embedProfileIfNone profile
-m, --matchTo profile
-M, --matchToWithIntent profile intent
--deleteColorManagementProperties
-r, --rotate degreesCW
-f, --flip horizontal|vertical
-c, --cropToHeightWidth pixelsH pixelsW
--cropOffset offsetY offsetH
-p, --padToHeightWidth pixelsH pixelsW
--padColor hexcolor
-z, --resampleHeightWidth pixelsH pixelsW
--resampleWidth pixelsW
--resampleHeight pixelsH
-Z, --resampleHeightWidthMax pixelsWH
-i, --addIcon
--optimizeColorForSharing
-o, --out file-or-directory
-j, --js file
Other functions:
--debug Enable debugging output
-h, --help Show help
-H, --helpProperties Show help for properties
--man Generate man pages
-v, --version Show the version
--formats Show the read/write formats
批量修改圖片大小
通過sips的使用說明可以看到看到需要使用 -z
1嘶朱、不保存原圖
sips -z 120 100 文件夾/*.jpg
2、保存原圖,把修改后的批量放在一個新的文件夾
sips -z 120 100 源文件夾路徑/*.jpg --out 修改后保存文件夾路徑
批量修改圖片格式
1.cd 到圖片文件夾的目錄下 并且通過mkdir 新建一個文件夾 MacX
2.for i in *.jpg; do sips -s format png "${i}" --out MacX/"${i%jpg}"png;done
3.廢棄:for i in *.jpg; do sips -s format png $i --out MacX/$i.png;done(直接在原格式后加.png-eg:pic.jpg.png)
image.png
Tips:$在程序中的作用
https://www.zhihu.com/question/492953119/answer/2176337757