Compression is a key component in imaging systems hat have limited power, bandwidth, or other resources. In many applications, images are acquired to support a specific task such as target detection or classification. However, standard image compression techniques such as JPEG or JPEG2000 (J2K) are often designed to maximize image quality as measured by conventional quality metrics such as mean-squared error (MSE) or Peak Signal to Noise Ratio (PSNR). This mismatch between image quality metrics and ask performance motivates our investigation of image compression using a task-specific metric designed for the designated tasks. Given the selected target detection task, we first propose a metric based on conditional class entropy. The proposed metric is then incorporated into a J2K encoder to create compressed codestreams ha are fully compliant with the J2K standard. Experimental results illustrate that the decompressed images obtained using he proposed encoder greatly improve performance in detection/classification tasks over images encoded using a conventional J2K encoder.