Its a topic all artists shld familiarize themselves with and one that is discussed often..If you can paint high realism and copy a well known photo/artwork, and sell the work, you can indeed be done for copyright..Change say the color of background, change the shirt color and a few other points and then technically a judge may consider it changed enough not to be in breach of copyright..Its a grey area and one that at times is hard to judge BUT...Consider this, if you sell a one off item that is in breach of copyright, likely no one will give a hoot, the owner of the photograph likely wouldn't know nor care to sue you at a greater cost than what they would likely get out of it..Make a million copies of that artwork though, make a crapload of money then indeed someone may come for you..Just don't paint in a can of coke in Johnnys hand and you'll prob be all good LOL as trademark copyright is not something you want to take chances with and one that you will likely loose on if indeed the company that owns that trademark comes after you...
Composition is a harder thing, composition generally just refers to how an artists places items around the work for a specific need to rest the viewers eye or direct it to a place of interest, their are general rules in composition that many artists follow so no real need to worry about copyright, but if you are directly copying the images within that artists composed painting and its recognizable you could indeed find yourself in a copyright issue..Again with enough changes you may be good.
Creating one off replications using another persons image generally won't see you in trouble but if you can, try to get permission to use that photo etc as many won't mind or only ask for a small royalty, especially if you plan to print the image you create and sell a lot of them, best to protect your interests in that kind of scenario...