Текущие попытки: я пытался использовать команду osascript в macOS для вызова Adobe Photoshop. и запустите файл .jsx, но у меня возникают проблемы с выполнением скрипта, возникают такие ошибки (при попытке выполнения этих команд в терминале):
- Command: osascript -e 'tell application "Adobe Photoshop 2025" to do javascript ("path/to/my/jsx/file")'
Error: "Adobe Photoshop 2025 got an error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop."-> (8800) Expected: ;. - Command: osascript "path/to/my/jsx/file"
Error: Expected end of line, etc. but found “/”. (-2741) - Command: osascript -e 'tell application "Adobe Photoshop 2025" to do javascript (POSIX file "path/to/my/jsx/file")'
Error: "Can’t get POSIX file."
Мой код Python:
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import time
import subprocess
class PhotoHandler(FileSystemEventHandler):
def __init__(self, target_folder, script_path):
self.target_folder = target_folder
self.script_path = script_path
self.photo_count = 0
self.photos = []
def on_created(self, event):
if event.is_directory:
return
if event.src_path.endswith(('.jpg', '.jpeg', '.png', '.ARW')):
self.photos.append(event.src_path)
self.photo_count += 1
if self.photo_count == 3:
self.process_photos()
self.photo_count = 0
self.photos = []
def process_photos(self):
applescript_path = "/Users/ishikagurnani/Documents/runjavascript.scpt"
print(f"Photos detected: {self.photos}")
try:
# Call Photoshop script
subprocess.run(
["osascript", applescript_path],
check=True
)
print("Photoshop script executed successfully!")
except subprocess.CalledProcessError as e:
print(f"Error running Photoshop script: {e}")
# Configuration
folder_to_watch = r"/Users/ishikagurnani/Pictures/Test/Auto Imported Photos"
script_path = r"/Users/ishikagurnani/Documents/full_automate_photobooth.jsx"
event_handler = PhotoHandler(folder_to_watch, script_path)
observer = Observer()
observer.schedule(event_handler, folder_to_watch, recursive=False)
observer.start()
try:
print("Monitoring folder for new photos...")
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
Подробнее здесь: https://stackoverflow.com/questions/793 ... sx-scripts