Search code examples
iosswiftapple-intelligence

Why is ImagePlaygroundViewController sourceImage not working?


I'm trying to create a ImagePlaygroundViewController in my iOS application and it works great. However when I try to pass in a sourceImage property it doesn't use that sourceImage as the base for the image it generates. Normally with ImagePlayground it shows the image around the image it generates, but it isn't doing that.


Solution

  • It took me hours of research to figure out what is going on here. There are a few requirements in order for ImagePlayground to use your sourceImage.

    • Image must be at least 384x384 pixels
    • Image must be no larger than 4096x4096 pixels
    • Image must be square

    While Apple does mention the recommended sizes in the documentation they make it sound like it's a recommendation as opposed to a requirement. Additionally Apple doesn't mention anything about the image needing to be square.

    For some reason when you manually add an image to an ImagePlayground it doesn't seem like any of these requirements apply. It seems to only apply when passing in images through that sourceImage property.

    I tested this on iOS 18.2 (22C5131e) and Xcode 16.1 (16B40).


    Edit: I just tested this some more. And it looks like images larger than 2048x2048 pixels also do not work. This was tested on the same versions as mentioned above.