Search code examples
wxpython

How do I crop an image using wxPython?


I want to extract a subimage from a wxImage by using the two-point coordinates or one point and the size.

I assumed that Resize() was supposed to do that, but it looks that it doesn't give the desired results.

For example doing Resize(Size(10,10),Point(0,0)) will give me the right results top-left 10x10 subimage.

Now if I want to get something else I'm kinda lost in two-dimensional space ;)


Solution

  • It seems that Resize() works in ways that are not well explained :p

    Here is the crop solution: cropped = WxImage.GetSubImage(rect)