Google Gemini coughed up the following hairball that after a bit of massaging I was able to get to work.

I barely tested it after getting it running and I CANNOT vouch for the code at all. If you're going to use it for any real-world purpose I highly recommend working through it to try to understand what it is doing first, then clean it up/do it right (I have not tried to understand the code at all, and reiterate that I DO NOT recommend it for any use other than study/proof-of-concept).

GDIPCrop.zip