I was wondering how to get the Image object from the layer

When I was writing the code script, I found that there was no API to get the Image from the Imagelayer,Thank!!

There is ImageLayer.imageSource. If you actually need to load the image, you can use the Image class. Does that help?

I want to get the width and height of its Image from imageLayer. Imagelayer. imageSource can only get path. I want an Image Object

Right, currently you can only get the image size by loading it using the Image class and then getting the size from there. This isn’t ideal, so I’ve just added an ImageLayer.image property for the upcoming Tiled 1.9 release:

1 Like

Thank you very much, but the “imageSource” attribute has unexpected strings. To successfully create a new Image Object with “image.load (path)” you also need to get the real path from it. Thank you again

Yeah, the imageSource property is exposed as a URL, because that’s the way it is stored internally. This is indeed not ideal, since image.load takes a local file path rather than a URL.

Fortunately the 1.9 release is scheduled for tomorrow. :slight_smile: