sample.py
import photos
import os
import tempfile
from PIL import Image
imageName = 'lena.png'
img = Image.open(imageName)
temp_path = os.path.join(tempfile.gettempdir(),imageName)
img.save(temp_path)
photos.create_image_asset(temp_path)
The function to add an image is photos.create_image_asset ()
, but since the image must be saved somewhere, it feels like getting temp_path
and saving it there once. is.
It's kind of smarter than saving it in the same directory where the script is.
Recommended Posts