欧美亚洲综合成人a∨在线,中文在线中文a,一二三四在线观看免费视频 ,在教室伦流澡到高潮h,亚洲综合性av私人影院

免費(fèi)加水印小軟件

下載地址

您的位置:首頁 > > 軟件下載 > 應(yīng)用軟件 > 編程開發(fā) > 批量加水印工具
95.56%
4.44%

免費(fèi)加水印小軟件 V2.0

  • 軟件介紹
  • 軟件截圖
  • 相關(guān)下載
軟件標(biāo)簽:

7.5第一次更新

在PNG基礎(chǔ)上追加jpg,jpeg,bmp格式(真的需要其他格式的水印嗎...)
現(xiàn)在上傳完的水印圖片會(huì)在按鈕內(nèi)顯示水印的預(yù)覽圖啦!
現(xiàn)在選擇完圖片也會(huì)顯示生成了多少張圖片和生成的路徑,并且添加了一個(gè)小進(jìn)度條
免費(fèi)加水印小軟件

以下是代碼

import os
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QPushButton, QFileDialog, QGridLayout, QSizePolicy, QLabel, QProgressBar
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import Qt, QSize
from PIL import Image
 
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("水印工具2.0")
        self.setWindowIcon(QIcon("push.ico"))
 
        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)
        self.layout = QGridLayout(self.central_widget)
        self.layout.setSpacing(0)
 
        self.watermark_path = ""
        self.image_paths = []
        self.output_folder = ""
 
        self.watermark_button = QPushButton("選擇水印圖片")
        self.watermark_button.clicked.connect(self.select_watermark)
        self.layout.addWidget(self.watermark_button, 2,0)
 
        self.image_button = QPushButton("選擇圖片")
        self.image_button.clicked.connect(self.select_images)
        self.layout.addWidget(self.image_button, 2, 1)
 
        self.folder_label = QLabel()
        self.layout.addWidget(self.folder_label, 3, 0)
 
        self.folder_button = QPushButton("選擇輸出文件夾")
        self.folder_button.clicked.connect(self.select_output_folder)
        self.layout.addWidget(self.folder_button, 4, 0)
 
        self.start_button = QPushButton("開始添加水印")
        self.start_button.clicked.connect(self.start_watermarking)
        self.layout.addWidget(self.start_button, 4, 1)
 
        self.progress_bar = QProgressBar()
        self.layout.addWidget(self.progress_bar, 5, 0, 1, 2)
 
        self.central_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.watermark_button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.image_button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.folder_button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.start_button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
 
        self.central_widget.setLayout(self.layout)
        self.setMinimumSize(500, 500)
        self.show()
 
    def select_watermark(self):
        file_dialog = QFileDialog()
        file_dialog.setNameFilter("Image files (*.png *.jpg *.jpeg *.bmp)")
        if file_dialog.exec_():
            self.watermark_path = file_dialog.selectedFiles()[0]
            pixmap = QPixmap(self.watermark_path)
            pixmap = pixmap.scaled(self.watermark_button.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
            scaled_path = os.path.join(os.path.dirname(self.watermark_path), "scaled_watermark.png")
            pixmap.save(scaled_path)
            scaled_path = scaled_path.replace('\\', '/')  # 將路徑中的反斜杠替換為正斜杠
            self.watermark_button.setStyleSheet(f"QPushButton {{background-image: url({scaled_path}); background-position: center; background-repeat: no-repeat; background-attachment: fixed}}")
 
    def select_images(self):
        file_dialog = QFileDialog()
        file_dialog.setNameFilter("Image files (*.png *.jpg *.jpeg)")
        file_dialog.setFileMode(QFileDialog.ExistingFiles)
        if file_dialog.exec_():
            self.image_paths = file_dialog.selectedFiles()
 
            # 在按鈕上顯示選擇的文件數(shù)量
            self.image_button.setText(f"選擇圖片 ({len(self.image_paths)})")
 
            pixmap = QPixmap(self.image_paths[0])
            pixmap = pixmap.scaled(self.image_button.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
            pixmap.save("scaled_image.png")
            self.image_button.setStyleSheet("QPushButton {background-image: url(" + os.path.abspath("scaled_image.png") + "); background-position: center; background-repeat: no-repeat; background-attachment: fixed}")
 
    def select_output_folder(self):
        file_dialog = QFileDialog()
        file_dialog.setFileMode(QFileDialog.DirectoryOnly)
        if file_dialog.exec_():
            self.output_folder = file_dialog.selectedFiles()[0]
            self.folder_button.setText("輸出文件夾: " + self.output_folder)
 
    def start_watermarking(self):
        self.progress_bar.setMaximum(len(self.image_paths))
 
        for index, image_path in enumerate(self.image_paths):
            image = Image.open(image_path)
            watermark = Image.open(self.watermark_path)
            watermark = watermark.resize(image.size, Image.ANTIALIAS)
            image.paste(watermark, (0,0), watermark)
            image.save(os.path.join(self.output_folder, os.path.basename(image_path)))
            self.progress_bar.setValue(index + 1)
 
if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    app.setWindowIcon(QIcon("ppush.ico"))  # 設(shè)置應(yīng)用程序的圖標(biāo),將顯示在任務(wù)欄
    sys.exit(app.exec_())

免費(fèi)加水印小軟件 V2.0

普通下載地址:
本地普通下載
本地電信下載
浙江移動(dòng)下載
北京聯(lián)通下載

相關(guān)下載

精選軟件