Hyperspectral (HS) image sensors measure the reflectance of each pixel at a large number of narrow spectral bands, creating a three-dimensional representation of the captured scene. The HS image (HSI) consumes a great amount of storage space and transmission time. Hence, it would be desirable to reduce the image representation to the extent possible using a compression method appropriate to the usage and processing of the image. Many compression methods have been proposed aiming at different applications and fields. This research focuses on the lossy compression of images that contain subpixel targets. This target type requires minimum compression loss over the spatial dimension in order to preserve the target, and the maximum possible spectral compression that would still enable target detection. For this target type, we propose the PCA-DCT (principle component analysis followed by the discrete cosine transform) compression method. It combines the PCA's ability to extract the background from a small number of components, with the individual spectral compression of each pixel of the residual image, obtained by excluding the background from the HSI, using quantized DCT coefficients. The compression method is kept simple for fast processing and implementation, and considers lossy compression only on the spectral axis. The spectral compression achieves a compression ratio of over 20. The popular Reed-Xiaoli (RX) algorithm and the improved quasi-local RX (RX <sub xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">QLC</sub> ) are used as target detection methods. The detection performance is evaluated using receiver operating characteristics (ROC) curve generation. The proposed compression method achieves maintained and enhanced detection performance, compared to the detection performance of the original image, mainly due to its inherent smoothing and noise reduction effects. Our proposed method is also compared with two other compression methods: PCA-ICA (independent component analysis) and band decimation (BandDec), yielding superior results for high compression rates.