OK I think I found a workaround. Ugly, but servicable until this gets fixed in the mainline: I retrieve the share sheet image in PIL format as desired, but then convert it to to "ui" format before pushing to the clipboard. For all other uses, I have a PIL object with all the right methods.
In case anyone else runs into this, this code shows the workaround:
import importlib import importlib.util import io import ui from PIL import Image def pil2ui(pil_img): with io.BytesIO() as buffer: pil_img.save(buffer, format='PNG') return ui.Image.from_data(buffer.getvalue()) def main(): print("Starting test") # check to see if appex library is available appex_spec = importlib.util.find_spec("appex") FOUND_APPEX_LIBRARY = appex_spec is not None if FOUND_APPEX_LIBRARY: import appex import clipboard import shortcuts if appex.is_running_extension(): my_image = appex.get_image(image_type="pil") # workaround: force to 'ui' format my_new_image = pil2ui(my_image) print("Setting clipboard image") r1 = clipboard.set_image(my_new_image, format="png", jpeg_quality=1.0) print("Finished setting clipboard image") else: print("This demo is for Pythonista running in an extension") if __name__ == "__main__": main()