sips批量修改圖片大小和格式簡單使用

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 強烈推薦一個macOS命令行小工具——sips,用于壓縮大量高清原圖非常方便。 使用范例://批量修改圖片大小,調(diào)...
    unix7閱讀 1,415評論 0 0
  • 溝通創(chuàng)造價值,分享帶來快樂。這里是程序員周刊,歡迎您每周五和我一起做時間的朋友。當(dāng)程序員冰墩墩脫掉帽子 并不是社會...
    張飛洪閱讀 279評論 0 0
  • 在使用Mac的時候,很多場景下我們都需要使用到截屏。不得不說,在MacOS中進行截屏是一件相當(dāng)輕松的事情,因為Ma...
    Mac高級玩家閱讀 6,655評論 1 7
  • 一.盒模型 盒模型的組成,由里向外content,padding,border,margin。盒模型有兩種標(biāo)準(zhǔn),一...
    Riyar閱讀 514評論 0 0
  • 人類最古老、最強烈的情感是恐懼,最古老、最強烈的恐懼是對未知的恐懼?!?本文無恐怖與令人嚴(yán)重不適圖片,可放心閱讀 ...
    保持風(fēng)度閱讀 517評論 0 1

友情鏈接更多精彩內(nèi)容