How to Get Image edge size 2D??

Hello guys, i’m trying to make an algorithm to create procedural scenery, and need to spawn the next sprite right at the end of last sprite, that i got, but i need to spawn in the right height too…

I need to get the lateral collidable height of my sprite, like this:

i’m guessing you are using a tile sheet and semi-randomly placing them next to each other at run time. the first way that comes to mind doesn’t actually get the height of them, it merely has 2 stored values per tile and you compare them before placing the new one.

if your not using a tile sheet, and some how generating the image of the terrain as it goes, then the way to get the height, is to check the value of each pixel on the far right column until you finds one that is non-transparent. and return the difference between there and the tiles pixel height.

the first would use more memory, but the second more time per tile placed.