iOS 馬甲包(一)圖片輕量級(jí)壓縮改變hash值

圖片輕量級(jí)壓縮主要是通過(guò)imagemagick軟件來(lái)實(shí)現(xiàn),我們通過(guò)homebrew軟件來(lái)安裝
1. 安裝homebrew

命令行輸入:/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

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

下載進(jìn)度 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/lixuewen/Library/Caches/Homebrew ==> /usr/bin/sudo /usr/sbin/chown lixuewen /Users/lixuewen/Library/Caches/Homebrew ==> Downloading and installing Homebrew... remote: Counting objects: 108116, done. remote: Compressing objects: 100% (17/17), done. remote: Total 108116 (delta 5), reused 14 (delta 5), pack-reused 108093 Receiving objects: 100% (108116/108116), 24.52 MiB | 34.00 KiB/s, done. Resolving deltas: 100% (79025/79025), done. From https://github.com/Homebrew/brew

如果提示出錯(cuò)了Error: /usr/local/Cellar is not writable. You should change the
ownership and permissions of /usr/local/Cellar back to your
user account:

輸入下面的命令行 sudo chown -R $(whoami) /usr/local/Cellar

然后繼續(xù)安裝輸入上面的安裝指令
檢測(cè)是否安裝成功

brew

如果安裝成功了,會(huì)返回如下命令

  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA

Contributing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
https://docs.brew.sh

2 安裝安裝x11,因?yàn)閙untain lion已經(jīng)刪除了x11
https://www.xquartz.org

3 安裝完xQuartz之后開(kāi)始安裝ghostscript,這個(gè)linux本來(lái)就安裝了,但是mac沒(méi)

brew install ghostscript

Updating Homebrew... ==> Installing dependencies for ghostscript: jpeg, libtiff, little-cms2 ==> Installing ghostscript dependency: jpeg ==> Downloading https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring jpeg--9c.high_sierra.bottle.tar.gz ?? /usr/local/Cellar/jpeg/9c: 21 files, 724.5KB ==> Installing ghostscript dependency: libtiff ==> Downloading https://homebrew.bintray.com/bottles/libtiff-4.0.9_4.high_sierra.bottle.tar ######################################################################## 100.0% ==> Pouring libtiff--4.0.9_4.high_sierra.bottle.tar.gz ?? /usr/local/Cellar/libtiff/4.0.9_4: 246 files, 3.5MB ==> Installing ghostscript dependency: little-cms2 ==> Downloading https://homebrew.bintray.com/bottles/little-cms2-2.9.high_sierra.bottle.1.t ######################################################################## 100.0% ==> Pouring little-cms2--2.9.high_sierra.bottle.1.tar.gz ?? /usr/local/Cellar/little-cms2/2.9: 18 files, 1MB ==> Installing ghostscript ==> Downloading https://homebrew.bintray.com/bottles/ghostscript-9.23.high_sierra.bottle.ta ######################################################################## 100.0% ==> Pouring ghostscript--9.23.high_sierra.bottle.tar.gz ?? /usr/local/Cellar/ghostscript/9.23: 679 files, 64.3MB

4.最后安裝imagemagick

 brew install imagemagick

輸入命令進(jìn)行壓縮

$ cd /Users/lixuewen/Desktop/未命名文件夾\ 2 
$ find . -iname "*.png" -exec echo {} \; -exec convert {} -quality 95 {} \;

一些其他用法

更改文件類(lèi)型
$  convert input.jpg output.png
 1)增加有色邊
convert -bordercolor red -border 25x25 image.jpg image.gif
 2)加亮或變暗圖片邊緣,以增強(qiáng)3D效果
convert -raise 25 image.jpg image.gif
 3)在圖片周?chē)黾友b飾性框架。
convert -mattecolor gray -frame 25x25 image.jpg image.gif
 4)在圖片邊緣增加升、降斜角
convert -mattecolor gray -frame 25x25+0+25 image.jpg image.gif
convert -mattecolor gray -frame 25x25+25+0 image.jpg image.gif
5)將gif文件分析為一系列的單個(gè)圖片
convert animation.gif frame%02d.gif
6)創(chuàng)建一張空白圖片
convert -size 800x600 xc:"#ddddff" ltblue.ppm
convert -size 800x600 null:white white.ppm
convert in.png -threshold 100% black.ppm #<--與in.png同大小

Mac: 文件校驗(yàn)終端命令查看文件哈希值,md5

`MD5`
$ md5 文件路徑

`SHA1`
$ shasum 文件路徑 
或者
$ openssl dgst -sha1 文件路徑

`SHA256`
openssl dgst -sha256 文件路徑

例:

bogon:未命名文件夾 2 lixuewen$ convert ert.jpg 111.png
bogon:未命名文件夾 2 lixuewen$ shasum /Users/lixuewen/Desktop/未命名文件夾\ 2/ert.jpg 
`d0b0df3d1c1c72f7ea8f8512fb99e8aa7815fbc2`  /Users/lixuewen/Desktop/未命名文件夾 2/ert.jpg
bogon:未命名文件夾 2 lixuewen$ shasum /Users/lixuewen/Desktop/未命名文件夾\ 2/111.png 
`0a51d4c26c9102132038f54986ca2ff575b7e6ab`  /Users/lixuewen/Desktop/未命名文件夾 2/111.png
bogon:未命名文件夾 2 lixuewen$ find . -iname "*.png" -exec echo {} \; -exec convert {} -quality 95 {} \;
./111.png
bogon:未命名文件夾 2 lixuewen$ shasum /Users/lixuewen/Desktop/未命名文件夾\ 2/111.png 
`392477f3b6ecdb2baeee903117a22731d26a1dba`  /Users/lixuewen/Desktop/未命名文件夾 2/111.png

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

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

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