Paint.net is a great open source (and thus: free) graphical application with which you can do great things. It's using layered mechanisms to build up an image in different stages.
I'm using it for years already and it's one of the most complete and user friendly graphical applications I know. Note that I'm not a graphical designer and my needs for a graphical application might not be the same as a professional graphical designer...
When the canvas is bigger than the image and you want to resize the canvas to perfectly match the size of the image, execute the following steps:
Use the magic wand and select the empty area(s) around the image. Make sure the tolerance is set in such a way that it fits your needs (mostly, it should be 0%).
A selection will be visible.
Press Ctrl-I: this will "inverse" the selection and select the image itself.
Now comes the trick: while the image is selected, select the crop symbol. This will result in removing the surrounding area and bring the size of the canvas to the same measurements as the size of the image.