An image watermark parameter optimization procedure is proposed for selecting the most effective DCT coefficients for watermark embedding. Using this set of coefficients improves the watermark robustness and reliability against attack while it maintains the transparency of the embedded watermark. With the aid of prior knowledge of attacks, the visual masking effect and the attack distortion on each (DCT) transform coefficient are pre-calculated so that a maximum strength watermark within visual threshold can be inserted. There are two stages in the design phase. First, taking into account the combined effect of watermark embedding and attack, we pick up the robust coefficients that resist a specific type of attacks and in the meanwhile we keep the distortion lower than the visual threshold. Although typically the watermark detection reliability increases with the increasing number of embedded coefficients, the less effective coefficients may degrade the overall detection performance. Thus, in the second stage, some initially selected coefficients are discarded by an iterative process to reduce the overall error detection probability. Since digital images are often compressed for efficient storage and transmission, we adopt JPEG compression as the attacking source. The simulation results show that the detection error probability is significantly reduced when the selected robust coefficients are in use. These coefficients with watermark embedded on them can also survive color reduction, Gaussian filtering, and frequency mode Laplacian removal (FMLR) attacks.