How to cut off the blank border area of a PNG image and shrink it to its minimum size using Python?
You can use PIL to find rows and cols of your image that are made up purely of your border color.
Using this information, you can easily determine the extents of the inlaid image.
PIL again will then allow you to crop the image to remove the border.