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