Why cropping is necessary - Aspect Ratio explained
Your camera takes a photo in a certain width:height ratio - otherwise known as its Aspect Ratio. Your canvas, however, is likely to be quite different. It might be square, it might be a standard A0 or A1 size. Even your "standard" stretched canvas comes in over 60 different sizes.
Getting the edges of your photograph to exactly match the edges of your painting will seldom be possible.
To crop your images, you can use a free online service such as https://pixlr.com/editor/.
The examples below use a scenario where a painting is to be photographed in an artist's studio. The same principles apply whether the location is your sitting room or your garden.
A1 painting, using a 16:9 (or HD) camera setting
Left and right sides of the photo will need cropping to eliminate unwanted background.
A1 painting, using a default 4:3 camera setting
4:3 aspect ratio is the default aspect of most consumer digital cameras and mobile phones. SLR digital cameras, and digital cameras that emulate a 35mm slide image, have a ratio of 3:2, in other words they're slightly wider for the same height.
This is the closest to an exact match of aspect ratios you're likely to get, and cropping won't be necessary.
A1 painting, using a square photograph
Top and bottom of the image will need to be cropped to eliminate unwanted background.
Wide landscape painting, using a 16:9 (or HD) camera setting
Although the aspect ratios are reasonably similar, top and bottom cropping will still be necessary to eliminate unwanted background.
Wide landscape painting, using a 3:2 (35mm) camera setting
Top and bottom image cropping will be necessary to eliminate unwanted background.
Square painting, using a 16:9 (HD) camera setting
Again, a lot of cropping from the sides will be necessary to eliminate unwanted background.
The Bottom Line
It's almost impossible to get the framing exactly right when you're taking the photograph.
The easiest approach is to not even bother trying to match the boundaries of your photograph with the edges of your painting. Simply take a quality high resolution photo, with some background. Your aim should be to get good quality lighting, and the correct exposure.
Try to get the edges of your painting straight, and don't even try to include a frame.
Then spend one or two minutes of your time to adjust, crop and re-size your image using https://pixlr.com/editor/. If you're serious about your art, it will be the best investment, completely free, you can make.