Skip to content

Images

The Y8 SDK allows your game to upload images to the authenticated player's Y8 profile.

This can be used for screenshots, custom creations, achievements, level designs, or other memorable moments from your game.

Authentication required

Image uploads require the player to be authenticated.


Submit an Image

Upload an image to the authenticated player's Y8 profile.

The image must be provided as a Base64 Data URL.

Creating an Image from a Canvas

const picture = document
    .getElementById("gameCanvas")
    .toDataURL("image/png");

Creating an Image from a Blob or File

function toDataURL(blob) {
    return new Promise((resolve, reject) => {

        const reader = new FileReader();

        reader.onload = () => resolve(reader.result);
        reader.onerror = reject;

        reader.readAsDataURL(blob);

    });
}

const picture = await toDataURL(imageBlob);

Upload the Image

y8Sdk.submitImage({
    picture: picture
})
.then((imageUrl) => {

    console.log("Image uploaded:", imageUrl);

})
.catch((error) => {

    console.error(error.message);

});

Parameters

Property Type Required Description
picture string Yes Base64 Data URL representing a PNG or JPEG image.

Response

When the upload succeeds, the Promise resolves with the public URL of the uploaded image.

const imageUrl = await y8Sdk.submitImage({
    picture
});

console.log(imageUrl);

The returned URL can be stored or shared by your game.

Supported Formats

  • image/png
  • image/jpeg

Capture an image and upload it to the player's Y8 profile.

Texture2D screenshotTexture = null;

StartCoroutine(TakeScreenshotCoroutine());

while (screenshotTexture == null)
{
    await Task.Yield();
}

JsResponse<SavedScreenshot> response =
    await Y8.Instance.SubmitImageAsync(screenshotTexture);

if (response.IsSuccess)
{
    Debug.Log(response.Data.imageUrl);
}

IEnumerator TakeScreenshotCoroutine()
{
    yield return new WaitForEndOfFrame();
    screenshotTexture = ScreenCapture.CaptureScreenshotAsTexture();
}

Parameters

Parameter Type Required Description
image Texture2D Yes Image to upload.

Response

When the upload succeeds, the returned response contains the public URL of the uploaded image.

if (response.IsSuccess)
{
    Debug.Log(response.Data.imageUrl);
}

Use Construct 3's Take snapshot of canvas action to capture the game canvas as a PNG.

Screenshot → On clicked
           → System: Take snapshot of canvas
              Format: PNG
              Quality: 75

Screenshot

Then handle the canvas snapshot:

System → On canvas snapshot
       → Call sendScreenshot
          image: CanvasSnapshot
Screenshot Screenshot

The C3 integration automatically processes the captured image and uploads it to the player's Y8 profile.

The image is converted to the required format internally before being submitted to Y8.

Upload an image using Y8.submitImage().

The image must be provided as a Base64 Data URL.

Y8.submitImage(picture);

Parameters

Parameter Type Required Description
picture String Yes Base64 Data URL representing the image to upload.

For example:

var picture:String = "data:image/png;base64,...";

Y8.submitImage(picture);

Authentication

Image uploads require an authenticated player.

Ensure the player is authenticated before calling submitImage().

Ensure the player is authenticated before calling SubmitImageAsync().

If the player is not logged in, the image upload is not performed.

Ensure the player is authenticated before calling Y8.submitImage().


Best Practices

  • Upload only images that are meaningful to the player.
  • Ensure the player is authenticated before uploading.
  • Use PNG or JPEG images supported by Y8.
  • Prefer PNG for screenshots and pixel art.
  • Convert images to the required format before uploading.
  • Avoid uploading screenshots unnecessarily.
  • Handle upload errors appropriately.

Platform-Specific Notes

Use JSON-compatible data and Base64 Data URLs when preparing images for upload.

Capture or create the Texture2D before calling SubmitImageAsync().

Use the Take snapshot of canvas action and handle the resulting canvas snapshot.

Provide the image as a Base64 Data URL.