Check if local image differs from image on Craft
It is related to the linked question since any images uploaded through Craft's AssetsService go through a "cleansing" process to remove any potentially embedded malicious scripts so the file size will inevitably be +/- the original by a small percentage.

What you can do is instead of uploading through the AssetsService, programmatically copy the file to the final destination on the file system in an Asset Source, then trigger Asset indexing like how the ToolsController does for the AssetIndexTool.  That will bypass any cleansing operations.