mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
slight color adjustments
This commit is contained in:
@@ -3,22 +3,25 @@ import sys
|
||||
import time
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
|
||||
def take_screenshot(html_file, css_file, output_file):
|
||||
# Setup Chrome options
|
||||
chrome_options = Options()
|
||||
chrome_options.add_argument("--headless") # Run in headless mode, no GUI
|
||||
|
||||
# Set window size to at least 1920x1080
|
||||
chrome_options.add_argument("--window-size=1920,1080")
|
||||
|
||||
# Initialize Chrome WebDriver with the specified service and options
|
||||
chromedriver_path = '/usr/bin/chromedriver' # Replace with your actual path
|
||||
chromedriver_path = "/usr/bin/chromedriver" # Replace with your actual path
|
||||
service = Service(chromedriver_path)
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
|
||||
try:
|
||||
# Open the HTML file
|
||||
driver.get(f'file://{os.path.abspath(html_file)}')
|
||||
driver.get(f"file://{os.path.abspath(html_file)}")
|
||||
|
||||
# Apply the CSS file to the HTML
|
||||
apply_css_script = f"""
|
||||
@@ -35,32 +38,33 @@ def take_screenshot(html_file, css_file, output_file):
|
||||
|
||||
# Capture screenshot
|
||||
driver.save_screenshot(output_file)
|
||||
print(f'Screenshot saved to {output_file}')
|
||||
print(f"Screenshot saved to {output_file}")
|
||||
|
||||
finally:
|
||||
driver.quit()
|
||||
|
||||
def main(folder_path):
|
||||
# Assuming index.html is in the same directory as the CSS files
|
||||
html_file = '/mnt/nfs/pictures/Sony_Alpha_7_iv/103MSDCF/index.html'
|
||||
|
||||
def main(_folder_path):
|
||||
html_file = "/mnt/nfs/pictures/Analog/2465575/index.html"
|
||||
|
||||
# Check if the folder path exists
|
||||
if not os.path.exists(folder_path):
|
||||
print(f'Error: Folder path "{folder_path}" does not exist.')
|
||||
if not os.path.exists(_folder_path):
|
||||
print(f'Error: Folder path "{_folder_path}" does not exist.')
|
||||
return
|
||||
|
||||
# Iterate over all files in the folder
|
||||
for filename in os.listdir(folder_path):
|
||||
if filename.endswith('.css'):
|
||||
css_file = os.path.join(folder_path, filename)
|
||||
output_file = os.path.join(folder_path, f'{os.path.splitext(filename)[0]}.png')
|
||||
for filename in os.listdir(_folder_path):
|
||||
if filename.endswith(".css"):
|
||||
css_file = os.path.join(_folder_path, filename)
|
||||
output_file = os.path.join(_folder_path, "screenshots", f"{os.path.splitext(filename)[0]}.png")
|
||||
|
||||
# Take screenshot for this CSS file
|
||||
take_screenshot(html_file, css_file, output_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: python script_name.py folder_path')
|
||||
print("Usage: python script_name.py folder_path")
|
||||
else:
|
||||
folder_path = sys.argv[1]
|
||||
main(folder_path)
|
||||
|
||||
Reference in New Issue
Block a user