在 NODEJS 中批量合并图像

时间:2021-08-01 13:29:55

标签: javascript node.js

我想在 app.js 中批量合并图像。 在根文件夹中,我有 3 层图像,我想为每个独特的组合生成一个独特的图像,并保存到根目录,即大约 3375 个生成的图像。

所有图片都是 1000X1000 像素,并且都有透明背景。

A层有15张图片(a1.png、a2.png...) B层有15张图片(b1.png、b2.png...) C层有15张图片(c1.png、c2.png...)

我想得到类似 A1B13C6.png 的东西

我有一些创建组合的代码。

'''

from selenium import webdriver ## importing webdriver
import time ## importing waiting time fuctions
from selenium.common.exceptions import TimeoutException ## importing the timeout fuctions
driver = webdriver.Chrome()

## Setting the Timeout timer in seconds
MAX_TIMEOUT_SECONDS = 60
## Getting url from list "url"
urlsList = ['urlone','urltwo', 'urlthree', 'urlfour']
## Getting list of urls
for s in urlsList:
    urls = str(s)
    ## loop with timeout exception
    try:
        ## Activinting the Timeout fuctions
        driver.set_page_load_timeout(MAX_TIMEOUT_SECONDS)
        driver.get(urls)
        ## Clicking on tab
        systemTab = driver.find_element_by_xpath('/html/body/ul[1]/li[3]/a')
        systemTab.click()
        ## Clicking on Bottom
        buttonRaul = driver.find_element_by_xpath('/html/body/ul[2]/li[4]/a')
        buttonRaul.click()
        ## Clicking on confirmation
        buttomGoo = driver.find_element_by_xpath('/html/body/div[2]/div[2]/button')
        buttomGoo.click()
        time.sleep(5) ## Wait 5 seconds
    except TimeoutException:
        continue

driver.quit()

感谢您的帮助!

0 个答案:

没有答案