No one buys the M8 for the camera
The S5 is much superior in that department. However if your just using the image for social networks and not cropping in, the M8 can take some good shots.
Indeed if you reduced the res /size of an S5 picture so that they both were about the same size, then the difference is surprisingly marginal. However viewed both at 100% side by side and clearly the 16mp can capture more info than the 4mp.
......
Also tip ... The HDR mode on the m8 is not working properly. When I shoot in auto I tend to get VASTLY better results in lighting and clarity than in HDR mode - as the HDR mode tends to over expose far more than just standard Auto mode.
If you want to use HDR mode, try Googles own camera software. It produces better HDR shots than sense camera, so clearly there is some software issue there.
_____ unfair I know. 4mp v 34.4mp But yeah here you can see what I mean - cropped to fit this forum window/thread so that they both look same size and either is ok. Click on either and that's where the megapixels kick in. So viewed as a similar sized image to its rivals the M8 produces similar results, but viewed 100% and 4mp can't compete. But if you were sharing on Facebook / instagram / snapchat etc... then the difference between them would be negligable. Heck if you posted it in the tapatalk app on this forum - the difference would be negligible too as that crops and compresses images.
HTC m8 16:9 (4mp)
Image
Full res
http://easydesign.macmate.me/photosmru/m8.jpg
Lumia 1020 16:9 (34.4mp)
Image
Full res
http://easydesign.macmate.me/photosmru/lumia1020.jpg