I put this mess of a script in to it:
- Code: Select all
from PIL import Image
import time
from PIL import ImageFont
from PIL import ImageDraw
import matplotlib.pyplot as plt
import numpy as np
import datetime
time.sleep(0.5)
original = Image.open(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/1.jpg")
#time.sleep(0.8)
draw = ImageDraw.Draw(original)
font = ImageFont.truetype("Arial", 55)
draw.text((55, 23), datetime.datetime.now().strftime("%a %d %I:%M %p text"), (255, 70, 90), font=font)
plt.subplot(1, 2, 1)
plt.title("white text")
# plt.imshow(original)
original.save(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/1.jpg", optimize=True, quality=45)
original.save(f"{indigo.server.getInstallFolderPath()}/Web Assets/public/2.jpg", optimize=True, quality=45)
It gave me back
- Code: Select all
from datetime import datetime
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
import matplotlib.pyplot as plt
import numpy as np
import time
image_path = Path(indigo.server.getInstallFolderPath()) / "Web Assets" / "public"
time.sleep(0.5)
with Image.open(image_path / "1.jpg") as original:
draw = ImageDraw.Draw(original)
font = ImageFont.truetype("Arial", 55)
draw.text((55, 23), datetime.now().strftime("%a %d %I:%M %p text"), (255, 70, 90), font=font)
plt.subplot(1, 2, 1)
plt.title("white text")
# plt.imshow(original)
original.save(image_path / "1.jpg", optimize=True, quality=45)
original.save(image_path / "2.jpg", optimize=True, quality=45)
I'm super impressed and imagine this will enable me to wildly expand python scripting in my setup.
It's not so great at AppleScript though. This folder action gets and error:
- Code: Select all
on adding folder items to this_folder after receiving added_items
tell application "Photos"
set display_folder to folder "display"
repeat with i in items of display_folder
delete i
end repeat
end tell
repeat with i in added_items
set file_name to the name of i
if file_name ends with ".jpg" or file_name ends with ".png" or file_name ends with ".gif" then
tell application "Photos"
import i to display_folder. (error is on this line)
end tell
end if
end repeat
end adding folder items to