給圖片、視頻增加水印以確認(rèn)版權(quán)或者增加效果,是在媒體內(nèi)容信息經(jīng)常需要用到的技術(shù)。本文推薦一個開源免費Python腳本,可以在指定目錄及其子目錄中批量給圖像添加水印,當(dāng)然,你也可以集成到你的Web應(yīng)用中。
源碼地址:https://github.com/theitrain/watermark
該Python項目依賴于Pillow庫,需要先安裝它:
pip install pillow
如何使用:
執(zhí)行該項目的腳本可以攜帶幾個參數(shù):
放置水印的有效位置包括:
除了以上位置,其他位置都將報錯。
例子:
1.使用watermark.py,請指定位置、目標(biāo)目錄,并將水印/徽標(biāo)縮放為圖像寬度的30%:
python watermark.py './images' 'logo.png' --pos bottomright --new_dir './watermarked_images' --scale 30
2.使用watermark.py,請指定位置和目標(biāo)目錄:
python watermark.py './images' 'logo.png' --pos bottomright --new_dir './watermarked_images'
3.在水印周圍添加填充,請執(zhí)行以下操作:
python watermark.py './images' 'logo.png' --pos topleft --padding 20
本文鏈接:http://www.www897cc.com/showinfo-26-59675-0.html一個用于批量給圖片增加水印的Python庫
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。郵件:2376512515@qq.com