Often, all you can really do is make a loop, moving the sprite out a little at a time until it's free.
Last time I did this, I set a radius of 1 pixel, and starting at angle 0, I stepped the angle by 45, then when the angle wraps around to 0 again, I increase the radius.
Say....px,py is the player position, and collision(x,y) returns the collision state
col=1
a=0
r=1
while col=1
x=px+sin(a)*r
y=py+cos(a)*r
if collision(x,y)=0 then col=0
a=a+45
if a>359 then a=0 : r=r+1
wend
px=x
py=y
That will kinda spin the sprite from it's start position, 1 pixel up and no pixels along - and it'll wind round and round until it finds some free space. It will favor the top of the platforms, as the angle is set to 0 as the range increases.
It might also be worth storing the last free position of the object - and if all else fails, set the player back to that. For example, you might want to limit the range of pixels, or you might want to kill the player if the range is more than 3 or 4 pixels - so they still die if they get properly stuck, but little glitches shouldn't bother it.
Health, Ammo, and bacon and eggs!