I assume that you are using an array to plot the images on the screen, correct?
Prior to moving the character sprite in the desired direction, you could save the old X/Y coordinates, check to see if the move is valid or not, and update the X/Y if valid or restore the old if invalid.
You could calculate which part of the image array the character sprite is about to move into to determine whether or not the move is valid.
Example:
array is: map(16,16)
screen/window width is 512
screen/window height is 512 (each image is 32 pixels wide X 32 pixels high)
character sprite is at X/Y: 224,128
index map((224/32),(128/32)) [i.e your character sprite is standing on map(7,4)]
if the user input is to move left, you check the array at map(6,4), to see if the image there is one of the brown path images. The same would work if the input is to move up, you would check at map(7,3), etc.
This code would assume that the player position is on the border of a particular image. I assume you're going to want to move your player less than 32 pixels every time, so you would have to check if an image will be crossed over into based upon the user input and the amount moved every time.
Hope this helps.
You idiots! You've captured their stunt doubles!