Watermarking is a popular technology to protect the copyright of digital image from illegal infringement. Traditional watermarking algorithms cannot better resist the illegal tampering attacks, causing serious security issues. This paper aims to propose an image watermarking algorithm with ability against illegal tampering attacks. The original image should be firstly pre-processed, and its fragmentary characteristic function of local image block is used to generate watermark locations randomly. When the watermark is illegally tampered and damaged, the generated fragmentary characteristic factor can be used to reconstruct the original image. Finally, the forensics of original image is realised. The experimental results show that the proposed algorithm can effectively embed a watermark into image. Besides, the original image can be restored even if the watermark is damaged. It is also robust to the typical attacks and has ability against tampering over a large area of the image.